プログラムでプログラムでスパンテキストを変更する方法C#の進行テンプレートの内側には?
-
21-12-2019 - |
質問
次のUpdateProgress:
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="updCampos"
DynamicLayout="true">
<ProgressTemplate>
<div class="carregando">
<span id="sAguarde">Aguarde ...</span> <asp:Image ID="Image1" runat="server" ImageUrl="~/images/loading.gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
.
私は「Saguarde」スパンの中にネストしたテキストの「aguarde ...」の内容の後ろのコードで変更する必要がありますが、このスパンにアクセスする方法はわかりません。言語はC#です。
助けを感謝します。
解決
は、次のようにLabelを使用して<span>
コントロールを変更するだけです -
<asp:Label id="sAguarde" Text="Aguarde ..." runat="server" />
.
とコードベーインドから次のようにアクセスします -
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
所属していません StackOverflow