2011-02-12 68 views
0

我需要從稱爲BindTagCloud的ascx控件中調用一個方法,以便將其導出爲pdf文件。我怎樣才能做到這一點?調用ASCX控制方法

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); 
       } 
      } 
     } 
+0

看起來像你正在給我調用方法。 – Amy 2011-02-12 22:39:17

+0

BindTagCloud()是tagcloud.ascx.cs中的一種方法。我試圖在displaycloud.aspx.cs中調用它... – MiziaQ 2011-02-12 22:46:11

回答

0

只需應該添加一個公共方法BindTagCloud到代碼的用戶控制(ascx文件)的文件後面。然後你就可以在你的aspx頁面調用由引用的方法,用戶控件:

TagCloudControl1.BindTagCloud(); 

如果你沒有看到在IntelliSence窗口的方法,重建網站(在主菜單Build - >Rebuild Web Site

0

覆蓋Render方法用於用戶控制並使用HtmlTextWriter那裏。

0

如果我理解正確的話,那麼你要的是這樣的:

TagCloudControl1.BindTagCloud();