刚从asp转到asp.net,碰到一个怪问题从登陆画面转到confirm页判断是否有用户如有就到INDEX页,但是现在在登陆画面按button没反应老是停留在本页望各位高手给看看
这个是登陆页面pLogin.aspx里代码
<form id="form1" runat="server" >
<div>
<asp:TextBox ID="txtPWD" runat="server" Style="z-index: 100; left: 460px; position: absolute;
top: 117px" TextMode="password" ></asp:TextBox>
<asp:TextBox ID="txtUID" runat="server" Style="z-index: 101; left: 459px; position: absolute;
top: 74px"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Style="z-index: 102; left: 407px; position: absolute;
top: 122px" Text="密 码" Font-Bold="True" Font-Names="楷体_GB2312"></asp:Label>
<asp:Label ID="Label2" runat="server" Style="z-index: 103; left: 406px; position: absolute;
top: 77px" Text="用户名" Font-Bold="True" Font-Names="楷体_GB2312"></asp:Label>
<asp:Button ID="cmdLog" runat="server" Font-Bold="True" Font-Names="楷体_GB2312" Style="z-index: 104;
left: 486px; position: absolute; top: 172px" Text="登 录" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtUID"
ErrorMessage="用户名不能为空" Style="z-index: 105; left: 645px; position: absolute;
top: 75px" Width="116px"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtPWD"
ErrorMessage="密码不能为空" Style="z-index: 106; left: 648px; position: absolute; top: 120px"
Width="99px"></asp:RequiredFieldValidator>
</div>
</form>
下面是confirm.asp.cs主要代码
protected void Page_Load(object sender, EventArgs e)
{
DataSet Ds = new DataSet();
string UID;
string PWD;
UID = Request["txtUID"];
PWD = Request["txtPWD"];
Response.Write(UID);
SqlConnection Cn = new SqlConnection();
SqlCommand Cmd = new SqlCommand();
SqlDataAdapter Da = new SqlDataAdapter();
Cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Initial Catalog=etam;Data Source=HUAFLY";
Cn.Open();
Cmd.Connection = Cn;
Cmd.CommandText = "select AgentID from EL_AgentAcount where AgentID=" + UID + " and PWD='" + PWD + "'";
Da.SelectCommand = Cmd;
Da.Fill(Ds, "UID");
if (Ds.Tables[0].Rows.Count == 0)
{
Response.Write("用户名或者密码错误,按<a href='pLogin.aspx'>这里</a>返回");
}
else
{
Response.Redirect("index.htm");
}
}
这个是登陆页面pLogin.aspx里代码
<form id="form1" runat="server" >
<div>
<asp:TextBox ID="txtPWD" runat="server" Style="z-index: 100; left: 460px; position: absolute;
top: 117px" TextMode="password" ></asp:TextBox>
<asp:TextBox ID="txtUID" runat="server" Style="z-index: 101; left: 459px; position: absolute;
top: 74px"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Style="z-index: 102; left: 407px; position: absolute;
top: 122px" Text="密 码" Font-Bold="True" Font-Names="楷体_GB2312"></asp:Label>
<asp:Label ID="Label2" runat="server" Style="z-index: 103; left: 406px; position: absolute;
top: 77px" Text="用户名" Font-Bold="True" Font-Names="楷体_GB2312"></asp:Label>
<asp:Button ID="cmdLog" runat="server" Font-Bold="True" Font-Names="楷体_GB2312" Style="z-index: 104;
left: 486px; position: absolute; top: 172px" Text="登 录" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtUID"
ErrorMessage="用户名不能为空" Style="z-index: 105; left: 645px; position: absolute;
top: 75px" Width="116px"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtPWD"
ErrorMessage="密码不能为空" Style="z-index: 106; left: 648px; position: absolute; top: 120px"
Width="99px"></asp:RequiredFieldValidator>
</div>
</form>
下面是confirm.asp.cs主要代码
protected void Page_Load(object sender, EventArgs e)
{
DataSet Ds = new DataSet();
string UID;
string PWD;
UID = Request["txtUID"];
PWD = Request["txtPWD"];
Response.Write(UID);
SqlConnection Cn = new SqlConnection();
SqlCommand Cmd = new SqlCommand();
SqlDataAdapter Da = new SqlDataAdapter();
Cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Initial Catalog=etam;Data Source=HUAFLY";
Cn.Open();
Cmd.Connection = Cn;
Cmd.CommandText = "select AgentID from EL_AgentAcount where AgentID=" + UID + " and PWD='" + PWD + "'";
Da.SelectCommand = Cmd;
Da.Fill(Ds, "UID");
if (Ds.Tables[0].Rows.Count == 0)
{
Response.Write("用户名或者密码错误,按<a href='pLogin.aspx'>这里</a>返回");
}
else
{
Response.Redirect("index.htm");
}
}
解决方案 »
- 发布.net项目到服务器上报错Server Application Unavailable
- 如何取得一个HTML页面中的所有图片地址?
- ASP.NET和PHP性能对比
- 问在不需要再次读取数据库的情况下,取得DataGrid中的数据?
- 弱弱的问一下,从网上down的asp.net源码,编译不了,提示:尝试运行项目时出错:无法在 Web 服务器上开始调试。该项目没有配置为调试版。
- 写的第一个ASP.NET程序就运行不起来啊!救命啊!
- 如何让DataGrid控件响应鼠标移动事件?高分相求。。。。
- Asp.net如何制作博客中的热门标签排名和搜索?
- 关于数据类型的问题,高手们帮帮我!
- CrystalReport问题,请多指教
- 送分大行动
- checkBox全选问题!
http://www.cndigs.com/search.php?search=asp.net&tag=true再就是注意验证控件的用法,验证控件很容易引起提交没反应的问题
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }