title: How to update label.text in asp.net from code behind-values
body: <p>I want to popup a message everytime I click on a button.
  This popup shows some information and updates its labels according to my code behind-values.</p>
  
  <p>I tried different things like declare variable either <em>protected</em> or <em>public</em>:</p>
  
  <pre><code>Protected  test As string = "test"
  '(...)
  test = "another string"
  </code></pre>
  
  <p>And in .aspx file:</p>
  
  <pre><code>&lt;%=test%&gt;
  </code></pre>
  
  <p>But then I noticed I can't have <code>&lt;%=%&gt;</code> blocks within the attributes of server-side controls (such as <code>&lt;asp:Label&gt;</code>).
  I tried to set the <code>.Text</code> property in the code-behind itself and it works on <em>Page Load</em>, but I want to set the <code>.Text</code> values in another function dynamically.</p>
  
  <pre><code>Protected Sub Page_Load(object sender, EventArgs e)
      If Not Page.IsPostBack Then
         pagenumberLabel.Text = GetPagingCaptionString()
      End If
  End Sub
  </code></pre>
  
  <p>I've also tried to create an hidden button and perform the click via javascript but the values are not being passed.</p>
  
  <p>[.ASPx.VB]</p>
  
  <pre><code>Protected  fileName As string = ""
  
  Protected Sub UpdatePopup(ByVal fileName As String)
          'fileName = "write my file name"
          ASPxLabelName.Text = fileName 
          ' this doens't work (filename="")
  End Sub
  ' OR
  Protected Sub UpdateButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles UpdateButton.Click
          fileName = "write my file name"
          ASPxLabelName.Text = fileName 
          ' This works but it is not dynamic as wanted
  End Sub
  </code></pre>
  
  <p>[.ASPx]</p>
  
  <pre><code>&lt;dx:ASPxPopupControl ID="ASPxPopupControl1" runat="server" ClientInstanceName="ShowMessageInfo"
      CloseAction="CloseButton" CloseOnEscape="True" EnableViewState="False"
      PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter"
      HeaderText="HEADER" AllowDragging="True" Modal="True"
      PopupAnimationType="Fade" PopupAction="None" Width="400px"&gt;
      &lt;ContentCollection&gt;
          &lt;dx:PopupControlContentControl ID="PopupControlContentControl1" runat="server"&gt;
              &lt;dx:ASPxPanel ID="Panel1" runat="server"&gt;
                  &lt;PanelCollection&gt;
                      &lt;dx:PanelContent ID="PanelContent1" runat="server"&gt;
                          &lt;table cellspacing="0" cellpadding="5" width="100%"&gt;
                              &lt;tr&gt;
                                  &lt;td&gt;Name:&lt;/td&gt;
                                  &lt;td&gt;&lt;dx:ASPxLabel ID="ASPxLabelName" runat="server" Text=""&gt;
                                      &lt;/dx:ASPxLabel&gt;&lt;/td&gt;
                              &lt;/tr&gt;
                          &lt;/table&gt;
                          &lt;dx:ASPxButton ID="UpdateButton" runat="server" Text="Update Content"
                              style="display:none" AutoPostBack="False"&gt;
                              &lt;ClientSideEvents Click="function(s, e) { ShowMessageInfo.PerformCallback(); }" /&gt;
                          &lt;/dx:ASPxButton&gt;
                      &lt;/dx:PanelContent&gt;
                  &lt;/PanelCollection&gt;
              &lt;/dx:ASPxPanel&gt;
          &lt;/dx:PopupControlContentControl&gt;
      &lt;/ContentCollection&gt;
  &lt;/dx:ASPxPopupControl&gt;
  </code></pre>