How to programmatically change range text inside a ProgressTemplate in C #?

I have the following UpdateProgress:

<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="updCampos"
    DynamicLayout="true">
    <ProgressTemplate>
        <div class="carregando">
            <span id="sAguarde">Aguarde ...</span>&nbsp;&nbsp;<asp:Image ID="Image1" runat="server" ImageUrl="~/images/loading.gif" />
        </div>
    </ProgressTemplate>
</asp:UpdateProgress>

I need to change the code behind the text "Aguarde ...", which I am nested in the "sAguarde" area, but I do not know how to access this range. Language - C #.

Thank you very much for your help.

+4
source share
2 answers

Just change the control <span>to a shortcut like this -

<asp:Label id="sAguarde" Text="Aguarde ..." runat="server" />

and access it from codebehind as follows:

Label progressMessageLabel = UpdateProgress1.FindControl("sAguarde") as Label;
if (progressMessageLabel != null)
{
    progressMessageLabel.Text = "something";
}
+5
source

You can change the range to a server control:

<span id="sAguarde" runat="server">Aguarde ...</span>

Then you can access it from the code:

protected override void Render(HtmlTextWriter writer)
{
    if (update) // globally declared update boolean to check if the page is being updated 
    {
        HtmlGenericControl sAguarde = (HtmlGenericControl) UpdateProgress1.FindControl("sAguarde");
        sAguarde.InnerHTML = "Hi";
    }
    base.Render(writer);
}

, span ASP.NET.

: UpdateProgress

+4

All Articles