开发者

How to access an usercontrol from the code behind?

I have an usercontrol with fck editor for allowing user to add note in my aspx page, which allows the user all kind of text formatting.My need is that I have to access user control from the code behind and collect the content as the same f开发者_JAVA技巧ormat some one has entered in the fck editor.How can I do this?


I'll elaborate on Brian's answer. You need to expose the content from the UserControl by adding a public property:

public string Content
{
   get
   {
      return editor.Content;
   }
}

Then to get the content from the user control, just called the property from the Page's code beind:

protected void Page_Load(object sender, EventArgs e)
{
   string content = this.UserControl1.Content;
}


In the page, the page code-behind should be able to use it directly like:

this.uc1.<uc code-behind properties or methods>

So you can expose things from your user control by adding public properties or methods.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜