Come cambiare a livello di programmazione un testo di span all'interno di un modello di avanzamento in C #?
-
21-12-2019 - |
Domanda
Ho i seguenti aggiornamenti:
<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>
.
Ho bisogno di cambiare nel codice dietro il testo "AGUARDE ..." Contenuto che ho annidato all'interno del "Saguarde", ma non so come accedere a questo intervallo.La lingua è c #.
Molte grazie per l'aiuto.
Soluzione
Basta modificare il controllo <span>
con l'etichetta come segue -
<asp:Label id="sAguarde" Text="Aguarde ..." runat="server" />
.
e accedi da CodeBehind come segue -
Label progressMessageLabel = UpdateProgress1.FindControl("sAguarde") as Label;
if (progressMessageLabel != null)
{
progressMessageLabel.Text = "something";
}
. Altri suggerimenti
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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow