Reputation: 271
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);
}
}
}
Upvotes: 1
Views: 1975
Reputation: 4049
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
)
Upvotes: 2
Reputation: 96596
If I understand correctly, then what you want is this:
TagCloudControl1.BindTagCloud();
Upvotes: 1
Reputation: 23871
Override Render
method for the user control and use the HtmlTextWriter
there.
Upvotes: 1