主题:关于ASP.NET和DREAMWEAVER
fancycgx3650
[专家分:30] 发布于 2007-07-07 16:36:00
我用DW做了一个登录框login.htm,在ASP.NET中建一个login.aspx,让login.aspx调用login.htm,运行以后可以成功。
但是我把login.htm里的表格放在一个层里面,再用login.aspx调用就会出错,为什么?
回复列表 (共6个回复)
沙发
longlong16 [专家分:10670] 发布于 2007-07-07 17:23:00
可能与aspx原有的div冲突,或者加上div有html标记欠套有误。。,
板凳
fancycgx3650 [专家分:30] 发布于 2007-07-07 23:32:00
我换了一个方法。先用ASP.NET创建login.aspx,用DW打开它,建立一个表格(两个文本框放用户名和密码,分别为userName和userPwd,两个Button,一个提交,一个重置),然后在ASP.NET里编程,代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace 调试
{
public partial class main : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(IsPostBack)
{
string userName = Request.Form.Get("userName").ToString();
string userPwd = Request.Form.Get("userPwd").ToString();
SqlConnection con = new SqlConnection("server=.;database=login;uid=sa;pwd=;");
con.Open();
SqlCommand cmd=new SqlCommand("select count(*) from login whrer userName='"+userName+"'and userPwd='"+userPwd+"'",con);
int count = Convert.ToInt32(cmd.ExecuteScalar());
if (count > 0)
{
Response.Redirect("login.aspx");
}
else
{
Response.Redirect("loginFail.aspx");
}
}
}
}
}
运行成功后单击提交和重置都是清空,就没别的反映了。
请问错在哪里?
3 楼
jzyray [专家分:20610] 发布于 2007-07-08 12:21:00
最好把客户端代码发上来
4 楼
fancycgx3650 [专家分:30] 发布于 2007-07-08 21:32:00
这是客户端的代码
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="main.aspx.cs" Inherits="调试.main" %>
<!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 runat="server">
<title>无标题页</title>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
left:27px;
top:5px;
width:445px;
height:203px;
z-index:1;
}
-->
</style>
</head>
<body>
<p> </p>
<form id="form1" name="form1" method="post" action="">
<table width="500" border="1">
<tr>
<td width="154" height="37"><div align="right">用户名:</div></td>
<td width="330"><label>
<input type="text" name="userName" id="userName" />
</label></td>
</tr>
<tr>
<td height="38"><div align="right">密码:</div></td>
<td><label>
<input name="userPwd" type="text" id="userPwd" />
</label></td>
</tr>
<tr>
<td height="46" colspan="2"><label>
<div align="center">
<input type="submit" name="Submit" value="提交" />
<input type="reset" name="Submit2" value="重置" />
</div>
</label></td>
</tr>
</table>
</form>
<p> </p>
</body>
</html>
5 楼
longlong16 [专家分:10670] 发布于 2007-07-09 10:35:00
你这是html标记的input不是服务器端按钮,况且你没有给按钮加任何动作的代码,form的action也为空,如何让它有动作呢?要判断用户名和密码,设计一个服务器按钮,<asp:Button .../>然后在它的click事件里把你load里的代码剪切过来!
6 楼
dwlovery [专家分:30] 发布于 2007-10-02 23:39:00
用VS 2005 不是很方便么??
我来回复