title: Show Message Box if TextBox is Blank or Empty using C#
body: <p>I am trying to check first if users don not enter either User ID or Password, if either text box is blank or empty then  I want to show message box, if they enter both user id and password then I want to execute some other codes.  The problem I am having with the code is that the message does not show at all but the good thing is that it does not execute the other code. So I would like to see the message box to show up if both text boxes are empty.  I am not sure why the message box is not showing up even though I have used this same code in other functions and it worked.  thanks
  here is my button code for the ASPX</p>
  
  <pre><code> &lt;asp:Panel ID="Panel1" runat="server" BorderStyle="Groove" Height="109px" Visible="false"
              Width="870px" BackColor="#FFFFE1"&gt;
              &lt;asp:Label ID="Label2" runat="server" Text="DIGITAL SIGNATURE" Font-Bold="True" 
                  ForeColor="#FF3300"&gt;&lt;/asp:Label&gt;
              &lt;br /&gt;
              &lt;br /&gt;
  
              &lt;asp:Label ID="lblUID" runat="server" Text="User ID:"&gt;&lt;/asp:Label&gt;
              &lt;asp:TextBox ID="txtUID" runat="server" Height="22px" Width="145px"&gt;&lt;/asp:TextBox&gt; &amp;nbsp;&amp;nbsp;
              &amp;nbsp;&amp;nbsp;
  
              &lt;asp:Label ID="lblPass" runat="server" Text="Password:"&gt;&lt;/asp:Label&gt;
              &lt;asp:TextBox ID="txtPass" runat="server" Height="23px" TextMode="Password" style="margin-top: 0px"&gt;&lt;/asp:TextBox&gt;
              &lt;br /&gt;
              &lt;br /&gt;
              &amp;nbsp;&lt;asp:Button ID="btnSubmit" runat="server" Text="Submit" Width="183px"
                  onclick="btnSubmit_Click" 
                  OnClientClick="return confirm('Are you sure you want to submit?');" 
                  Font-Bold="False" Font-Size="Medium" Height="30px" 
                  style="margin-right: 1px" /&gt;
              &lt;br /&gt;
          &lt;/asp:Panel&gt;
  </code></pre>
  
  <p>code behind:</p>
  
  <pre><code>protected void btnSubmit_Click(object sender, EventArgs e)
      {
  
          if (txtUID.Text.Length == 0 || txtPass.Text.Length == 0)
          {
  
              ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please type your User ID and Password correctly and click Submit button again.  Thanks", true);
  
          }
  
          else
          {
  
                //execute some code here
          }
       }
  </code></pre>