When i click on a button to define its click event, it takes me to the tags of my own aspx page instead of taking me to the code behind/aspx.cs page. This happens for home page only. the other page signup.aspx works fine and does as expected.
This has happened for a number of projects with me in past few months and as i am a beginner, i don't have much idea about this. But yes i have tick marked "Place code in separate file" checkbox when creating this website in VS 2010.
Thanks in advance for your help.
Edit: (Added code)
<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Employee Login</title>
<link href="css/Style.css" type="text/css" rel="Stylesheet" />
</head>
<body>
<form id="form1" runat="server">
<div>
<table align="center" class="loginBox">
<tr>
<td>Username:</td>
<td><asp:TextBox ID="txtUsername" runat="server" CssClass="username"></asp:TextBox></td>
<asp:RequiredFieldValidator runat="server" ID="rqUser" ValidationGroup="loginValidation" ControlToValidate="txtUsername" ErrorMessage="Username"></asp:RequiredFieldValidator>
</tr>
<tr>
<td>Password:</td>
<td><asp:TextBox ID="txtPassword" runat="server" TextMode="Password" CssClass="password"></asp:TextBox></td>
<asp:RequiredFieldValidator runat="server" ID="rqPass" ValidationGroup="loginValidation" ControlToValidate="txtPassword" ErrorMessage="Password"></asp:RequiredFieldValidator>
</tr>
<tr>
<td align="center" colspan="2"><asp:Button ID="btnLogin" Width="60" runat="server"
Text="Login" CssClass="btnLogin" onclick="btnLogin_Click" /></td>
</tr>
<tr>
<td colspan="2"><span style="float:left;"><asp:HyperLink ID="HyperLink1" runat="server" Text="Forgot Password" NavigateUrl="~/forgotpassword.aspx" CssClass="regular_text"></asp:HyperLink></span>
<span style="float:right;"><asp:HyperLink ID="HyperLink2" runat="server" Text="New User" NavigateUrl="~/signup.aspx" CssClass="regular_text"></asp:HyperLink></span>
</td>
</tr>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="You must enter following" DisplayMode="BulletList" EnableClientScript="true" ForeColor="White" />
</table>
</div>
</form>
</body>
</html>
Code behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…