프로그래밍 방식으로 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