Search code examples
c#asp.nethtmlupdateprogress

How to change programatically a span 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 in the code behind the text "Aguarde..." content that i nested inside the "sAguarde" span, but I don't know how to access this span. The language is C#.

Many thanks for the help.


Solution

  • Just change your <span> control with Label as follows-

    <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";
    }