How to change programatically a span text inside a ProgressTemplate in C#?

Bruno Albuquerque picture Bruno Albuquerque · Feb 25, 2014 · Viewed 24.9k times · Source

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.

Answer

Microsoft DN picture Microsoft DN · Feb 25, 2014

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