Question

In my ASP.NET app I have Update Panel and Custom server control in it.

This Custom control has inside Literal Control. I try to set it's text property programmatically. But it doesn't render, because Literal Control is in Update Panel.

How can I solve this? Thanks very much.

Here is my code:

<asp:UpdatePanel runat="server" ID="updPanel">
<ContentTemplate>
    <st:AspGridViewTitlePanel runat="server" ID="GridTitle" Width="100%">                               
    </st:AspGridViewTitlePanel>     
</ContentTemplate>
</asp:UpdatePanel>

AspGridViewTitlePanel - it's my server control. It has such code:

this.myLiteralControl = new LiteralControl();
this.myLiteralControl.Text = "Some text";
Était-ce utile?

La solution

protected void page_load(object sender, args e) {
  if (!Page.IsPostBack) {
    LiteralControl myLiteralControl = new LiteralControl();
    myLiteralControl.Text = @"<span> MY TEXT </span>";
    UP1.ContentTemplate.Controls.Add(myLiteralControl);
  }
}

Adding controls dynamically to an UpdatePanel in ASP.NET AJAX

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top