code behind file is not accessing design file controls in asp.net VS 2017 RRS feed

  • Question

  • User-1525124014 posted

    This is front end code

    <label for="Email">Email address</label> <input type="email" class="form-control" id="Login_Email" runat="server" placeholder="Enter email" />
    <label for="Password">Password</label> <input type="password" class="form-control" id="Login_Password" runat="server" placeholder="Password" />
    <input type="checkbox" class="form-check-input" id="chkBoxRememberMe" runat="server" /> <label class="form-check-label">Remember Me</label>
    <button type="submit" class="btn btn-primary" runat="server" onclick="Login_button_Click">Login</button> <asp:label id="lblMessage" runat="server" text="Label"></asp:label></form>

    this is backend programme protected void Login_button_Click(object sender, EventArgs e) { if (Login_Authentication_Method(Login_Email.Text, Login_Password.Text)) { FormsAuthentication.RedirectFromLoginPage(Login_Email.Text, chkBoxRememberMe.Checked); } else { lblMessage.Text = "Invalid User Name and/or Password"; } }

    Thursday, April 18, 2019 6:49 PM

All replies

  • User2053451246 posted

    Do all of the controls and containers holding the controls (such as the <form>) have runat="server".  I see in your post the <form> tag does not have that.

    Thursday, April 18, 2019 8:33 PM
  • User288213138 posted

    Hi  nadir511,
    Your  front end code is Html server control, is not directly in the code behind the use of, HTML server control belong to the System. Web. UI. HtmlControls namespace, Web server control belong to the System. Web. UI. WebControls namespace ASP.NET server controls. If you want to use the HTML server control in the code behind, please add runat=”server” in the <form> tag. Such as <form id="form" runat="server"><form>.
    Best Regard,

    Friday, April 19, 2019 10:48 AM