Note that there are some explanatory texts on larger screens.

plurals
  1. POStrange behaviour on postback in ASP.NET
    primarykey
    data
    text
    <p>I'm working on a website with a login form. To log in, a postback is used to an OnClick handler in the codebehind.<br> Somehow, the value returned from the Text-property of the username and password textboxes is ten times the value I entered, separated by commas. I checked my entire code for double ID's (which seems to be the most common problem causing this behaviour), but I found each ID defined only once.</p> <p>In the ASPX file I have this:</p> <pre><code>&lt;asp:Label ID="lblFeedback" ForeColor="Red" Font-Bold="true" runat="server" Visible="false" /&gt;&lt;br /&gt; &lt;asp:Panel ID="pnlLogin" runat="server"&gt; &lt;table style="border-style: none;"&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:Label ID="lblUsername" AssociatedControlID="txtUsername" runat="server" /&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID="txtUsername" runat="server" /&gt;&lt;br /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:Label ID="lblPassword" AssociatedControlID="txtPassword" runat="server" /&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID="txtPassword" runat="server" TextMode="password" /&gt;&lt;br /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:Button ID="btnLogin" OnClick="btnLogin_Click" runat="server" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/asp:Panel&gt; </code></pre> <p>The OnClick handler in the Codebehind:</p> <pre><code>protected void btnLogin_Click(object sender, EventArgs e) { string username = Util.Escape(txtUsername.Text); string password = Util.Escape(txtPassword.Text); WebsiteUser user = WebsiteUser.Create(username, password); if (user != null) { //Set some session variables and redirect to user profile } else { lblFeedback.Text = Localizer.Translate("INVALID_LOGIN"); lblFeedback.ForeColor = Color.Red; lblFeedback.Visible = true; pnlLogin.Visible = true; } } </code></pre> <p>The website is running on ASP.NET 2.0 on ISS 5.1 (Win XP Pro)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload