我有以下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>
.

我需要更改文本后面的代码“aguarde ......”内容,我嵌套在“saguarde”跨度内,但我不知道如何访问这个跨度。语言是C#。

非常感谢您的帮助。

有帮助吗?

解决方案

只需更改使用标签的<span>控件,如下所示 -

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

并按Codebehind访问它,如下所示 -

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

其他提示

You could change the span to a serverside control:

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

Then you can access it from the codebehind:

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

But note that the span's id will be rendered using ASP.NET control naming conventions.

For full context, see: Changing the contents of the UpdateProgress control

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top