开发者

Calling ASCX control method

开发者 https://www.devze.com 2023-02-09 23:30 出处:网络
I need to call a method from my ascx control called BindTagCloud for the purpose of exporting it to a pdf file. How can I do that?

I need to call a method from my ascx control called BindTagCloud for the purpose of exporting it to a pdf file. How can I do that?

displaycloud.aspx:

<TagCloud:TagCloudControl ID="TagCloudControl1" runat="server" />

displaycloud.apsx.cs:

if (text.Length.Equals(0)) {

            --> BindTagCloud(); <--
            using (StringWriter sWriter = new StringWriter(strB)) {

                using (HtmlTextWriter htWriter = new HtmlTextWriter开发者_运维问答(sWriter)) {

                    TagCloudControl1.RenderControl(htWriter);
                }
            } 
        }


You simply should add a public method BindTagCloud to the Code Behind file of the user control (ascx file). Then you can call the method by reference to your user control in your aspx page:

TagCloudControl1.BindTagCloud();

If you don't see the method in the IntelliSence window, rebuild the Web Site (in the main menu Build -> Rebuild Web Site)


Override Render method for the user control and use the HtmlTextWriter there.


If I understand correctly, then what you want is this:

TagCloudControl1.BindTagCloud();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号