<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login_Person.aspx.cs" Inherits="Login_Person" %>
<!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>个人用户注册</title>
</head>
<body>
<form id="form1" runat="server">
<div runat = "server">
<center>
<table width = "750px">
<tr> <td style=" width:150px;height:82px; font-size: 20pt; font-family: 幼圆;">
水院信息港</td>
<td style="height: 82px"> </td>
</tr>
</table>
<table width = "750px">
<tr><td style="height:25px">
</td></tr>
</table>
<table width = "750px" style ="height :400px">
<tr>
<td style="width :200px; height: 390px; text-align: center;">
</td>
<td style="vertical-align: middle; text-align: center">
<table style="width: 440px; height: 318px" >
<tr>
<td colspan = "2">
个人新用户注册</td>
</tr>
<tr>
<td style="width: 140px" >
用户名:</td>
<td style="width: 300px" >
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 140px">
密码:</td>
<td style="width: 300px">
<asp:TextBox ID="Password" TextMode = "Password" runat ="server" Width="150px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 140px">
确认密码:</td>
<td style="width: 300px">
<asp:TextBox ID = "ConfirmPassword" TextMode = "Password" runat = "server" Width="150px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 140px">
性别:</td>
<td style="width: 300px">
<asp:RadioButton ID = "Male" runat = "server" Text = "男" GroupName = "Sex" Checked = "true" />
<asp:RadioButton ID = "Famale" runat = "server" Text = "女" GroupName = "Sex" Checked = "false" />
</td>
</tr>
<tr>
<td style="width: 140px">
电子邮件:</td>
<td style="width: 300px">
<asp:TextBox ID = "Email" runat = "server" ></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 140px">
联系电话:</td>
<td style="width: 300px">
<asp:TextBox ID = "Phone" runat = "server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 140px; height: 30px;">
安全提示问题:</td>
<td style="width: 300px; height: 30px;">
<asp:TextBox ID = "Question" runat = "server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 140px; height: 31px;">
安全答案:</td>
<td style="width: 300px; height: 31px;">
<asp:TextBox ID = "Answer" runat = "server"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan = "2" style="height: 25px">
<input type ="submit" value = "提交" runat = "server" id="Submit1" onserverclick="Submit1_ServerClick" />
<input type = "reset" value = "重置" runat = "server" />
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width = "750px">
<tr>
<td style="height: 55px"></td>
</tr>
</table>
</center>
</div>
</form>
</body>
</html>
但在“提交”按钮的事件写代码,往数据库中写东西,最后运行却提示:当前上下文不存在诸如:UserName,Password...也不知道是怎么回事,请教各位大虾!不胜感激!在线等!
17 个解决方案
#1
还有就是,关于
<asp:RadioButton ID = "Male" runat = "server" Text = "男" GroupName = "Sex" Checked = "true" />
<asp:RadioButton ID = "Famale" runat = "server" Text = "女" GroupName = "Sex" Checked = "false" />
两个控件在.cs代码中干脆就不识别,真是狂晕!我刚学用VS2005做网页,新手!
<asp:RadioButton ID = "Male" runat = "server" Text = "男" GroupName = "Sex" Checked = "true" />
<asp:RadioButton ID = "Famale" runat = "server" Text = "女" GroupName = "Sex" Checked = "false" />
两个控件在.cs代码中干脆就不识别,真是狂晕!我刚学用VS2005做网页,新手!
#2
按钮事件如下:
protected void Submit1_ServerClick(object sender, EventArgs e)
{
string P_name,P_password,P_sex,P_email,P_phone,P_question , P_answer;
P_name = P_password = P_sex = P_email = P_phone = P_question = P_answer = null;
P_name = UserName.Text.ToString();
P_password = Password.Text.ToString();
P_email = Email.Text.ToString();
P_phone = Phone.Text.ToString();
P_question = Question.Text.ToString();
P_answer = Answer.Text.ToString();
int Num;
DataBase db = new DataBase();
string strSql = "insert into Person_Information (name,password,email,phone,question,answer) values ('" + P_name + "','" + P_password + "','" + P_email + "','" + P_phone + "','" + P_question + "','" + P_answer + "')";
if (db.executeSql(strSql,out Num))
Response.Write("成功");
}
protected void Submit1_ServerClick(object sender, EventArgs e)
{
string P_name,P_password,P_sex,P_email,P_phone,P_question , P_answer;
P_name = P_password = P_sex = P_email = P_phone = P_question = P_answer = null;
P_name = UserName.Text.ToString();
P_password = Password.Text.ToString();
P_email = Email.Text.ToString();
P_phone = Phone.Text.ToString();
P_question = Question.Text.ToString();
P_answer = Answer.Text.ToString();
int Num;
DataBase db = new DataBase();
string strSql = "insert into Person_Information (name,password,email,phone,question,answer) values ('" + P_name + "','" + P_password + "','" + P_email + "','" + P_phone + "','" + P_question + "','" + P_answer + "')";
if (db.executeSql(strSql,out Num))
Response.Write("成功");
}
#3
是表示层的数据没有传递到数据层,可能是参数设置问题,还有可能是接口问题,有没有引用这个方法。你先看一下.cs文件吧
#4
不用那个ToString()的
#5
您能不能说的在详细一点?谢谢
#6
運行到哪里提示那個錯誤?
#7
你的数据库好像也没有连接啊
#8
我在protected void Submit1_ServerClick(object sender, EventArgs e)前设置断点,就不行了,就有错误!
#9
我是直接用代码打开的数据库
#10
不过我在我不点击“运行”直接选择在浏览器中查看,就没事,而且还可以写入数据库!
#11
<%@ Page Language="V#" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
Protected void sreGuestBook_Inserting(object sender,SqlDataSourceCommandEventArgs e)
{
e.Command,Parameters.Add(new SqlParameter("@Name",User.Identity.Name));
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Show ProfileParameter</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FormView
id="frmGuestBook"
DataSourceID="srcGuestBook"
DefaultMode="Insert"
Runat="server">
<InsertItemTemplate>
<asp:Label
id="lblComments"
Text="Enter Your Comments:"
Runat="server" />
<br />
<asp:TextBox
id="txtComments"
Text='<%# Bind("Comments") %>'
TextMode="MultiLine"
Columns="50"
Rows="4"
Runat="server" />
<br />
<asp:Button
id="btnInsert"
Text="Add Comments"
CommandName="Insert"
Runat="server" />
</InsertItemTemplate>
</asp:FormView>
<hr />
<asp:GridView
id="grdGuestBook"
DataSourceID="srcGuestBook"
Runat="server" />
<asp:SqlDataSource
id="srcGuestBook"
SelectCommand="SELECT Name,Comments,EntryDate
FROM GuestBook ORDER BY Id DESC"
InsertCommand="INSERT GuestBook (Name,Comments)
VALUES (@Name,@Comments)"
ConnectionString="<%$ ConnectionStrings:GuestBook %>"
Runat="server" OnInserting="srcGuestBook_Inserting" />
</div>
</form>
</body>
</html>
此代码供LZ参考
<%@ Import Namespace="System.Data.SqlClient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
Protected void sreGuestBook_Inserting(object sender,SqlDataSourceCommandEventArgs e)
{
e.Command,Parameters.Add(new SqlParameter("@Name",User.Identity.Name));
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Show ProfileParameter</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FormView
id="frmGuestBook"
DataSourceID="srcGuestBook"
DefaultMode="Insert"
Runat="server">
<InsertItemTemplate>
<asp:Label
id="lblComments"
Text="Enter Your Comments:"
Runat="server" />
<br />
<asp:TextBox
id="txtComments"
Text='<%# Bind("Comments") %>'
TextMode="MultiLine"
Columns="50"
Rows="4"
Runat="server" />
<br />
<asp:Button
id="btnInsert"
Text="Add Comments"
CommandName="Insert"
Runat="server" />
</InsertItemTemplate>
</asp:FormView>
<hr />
<asp:GridView
id="grdGuestBook"
DataSourceID="srcGuestBook"
Runat="server" />
<asp:SqlDataSource
id="srcGuestBook"
SelectCommand="SELECT Name,Comments,EntryDate
FROM GuestBook ORDER BY Id DESC"
InsertCommand="INSERT GuestBook (Name,Comments)
VALUES (@Name,@Comments)"
ConnectionString="<%$ ConnectionStrings:GuestBook %>"
Runat="server" OnInserting="srcGuestBook_Inserting" />
</div>
</form>
</body>
</html>
此代码供LZ参考
#12
可能是你的其他類文件有問題吧。
#13
曾经遇到过这样的问题,原因还是CodeFile="Login_Person.aspx.cs" Inherits="Login_Person" 没有关联上,去看下".cs文件里的类名是否跟aspx的Inherits一样,或者干脆把Inherits="Login_Person删除。
我当时遇到的情况是我复制了一份文件,也就是文件夹下有2个Login_Person.aspx和Login_Person.aspx.cs,是因我在修改是复制了一份,另一分叫复件Login_Person.aspx和复件Login_Person.aspx.cs,虽然文件名不一样,但是两个文件的Inherits一样,里面内容一样,所以在vs2005里编译运行时候可以,但写代码的时候提示找不到页面里的元素,把后者删除就可以了!不知道你有没有这种情况。
其他问题就不知道了,知道了在来回!
我当时遇到的情况是我复制了一份文件,也就是文件夹下有2个Login_Person.aspx和Login_Person.aspx.cs,是因我在修改是复制了一份,另一分叫复件Login_Person.aspx和复件Login_Person.aspx.cs,虽然文件名不一样,但是两个文件的Inherits一样,里面内容一样,所以在vs2005里编译运行时候可以,但写代码的时候提示找不到页面里的元素,把后者删除就可以了!不知道你有没有这种情况。
其他问题就不知道了,知道了在来回!
#14
aspx文件 Inherits="Login_Person"
.cs文件 public partial class Login_Person : System.Web.UI.Page{}
两个地方有没有对应上啊?
#15
另外推荐LZ多使用学习div+css布置表示层页面
#16
多谢Phper2008 按照你的说法我的问题解决了,
真是十分感谢Sorm531590401 不停的支持,都是在新建项目懒省劲,拷贝代码惹得祸!
接分!
真是十分感谢Sorm531590401 不停的支持,都是在新建项目懒省劲,拷贝代码惹得祸!
接分!
#17
呵呵,我也是好久没有来csdn了,今天偶尔来一下,当然得要认真回复喽:)
加油!LZ!
加油!LZ!
#1
还有就是,关于
<asp:RadioButton ID = "Male" runat = "server" Text = "男" GroupName = "Sex" Checked = "true" />
<asp:RadioButton ID = "Famale" runat = "server" Text = "女" GroupName = "Sex" Checked = "false" />
两个控件在.cs代码中干脆就不识别,真是狂晕!我刚学用VS2005做网页,新手!
<asp:RadioButton ID = "Male" runat = "server" Text = "男" GroupName = "Sex" Checked = "true" />
<asp:RadioButton ID = "Famale" runat = "server" Text = "女" GroupName = "Sex" Checked = "false" />
两个控件在.cs代码中干脆就不识别,真是狂晕!我刚学用VS2005做网页,新手!
#2
按钮事件如下:
protected void Submit1_ServerClick(object sender, EventArgs e)
{
string P_name,P_password,P_sex,P_email,P_phone,P_question , P_answer;
P_name = P_password = P_sex = P_email = P_phone = P_question = P_answer = null;
P_name = UserName.Text.ToString();
P_password = Password.Text.ToString();
P_email = Email.Text.ToString();
P_phone = Phone.Text.ToString();
P_question = Question.Text.ToString();
P_answer = Answer.Text.ToString();
int Num;
DataBase db = new DataBase();
string strSql = "insert into Person_Information (name,password,email,phone,question,answer) values ('" + P_name + "','" + P_password + "','" + P_email + "','" + P_phone + "','" + P_question + "','" + P_answer + "')";
if (db.executeSql(strSql,out Num))
Response.Write("成功");
}
protected void Submit1_ServerClick(object sender, EventArgs e)
{
string P_name,P_password,P_sex,P_email,P_phone,P_question , P_answer;
P_name = P_password = P_sex = P_email = P_phone = P_question = P_answer = null;
P_name = UserName.Text.ToString();
P_password = Password.Text.ToString();
P_email = Email.Text.ToString();
P_phone = Phone.Text.ToString();
P_question = Question.Text.ToString();
P_answer = Answer.Text.ToString();
int Num;
DataBase db = new DataBase();
string strSql = "insert into Person_Information (name,password,email,phone,question,answer) values ('" + P_name + "','" + P_password + "','" + P_email + "','" + P_phone + "','" + P_question + "','" + P_answer + "')";
if (db.executeSql(strSql,out Num))
Response.Write("成功");
}
#3
是表示层的数据没有传递到数据层,可能是参数设置问题,还有可能是接口问题,有没有引用这个方法。你先看一下.cs文件吧
#4
不用那个ToString()的
#5
您能不能说的在详细一点?谢谢
#6
運行到哪里提示那個錯誤?
#7
你的数据库好像也没有连接啊
#8
我在protected void Submit1_ServerClick(object sender, EventArgs e)前设置断点,就不行了,就有错误!
#9
我是直接用代码打开的数据库
#10
不过我在我不点击“运行”直接选择在浏览器中查看,就没事,而且还可以写入数据库!
#11
<%@ Page Language="V#" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
Protected void sreGuestBook_Inserting(object sender,SqlDataSourceCommandEventArgs e)
{
e.Command,Parameters.Add(new SqlParameter("@Name",User.Identity.Name));
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Show ProfileParameter</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FormView
id="frmGuestBook"
DataSourceID="srcGuestBook"
DefaultMode="Insert"
Runat="server">
<InsertItemTemplate>
<asp:Label
id="lblComments"
Text="Enter Your Comments:"
Runat="server" />
<br />
<asp:TextBox
id="txtComments"
Text='<%# Bind("Comments") %>'
TextMode="MultiLine"
Columns="50"
Rows="4"
Runat="server" />
<br />
<asp:Button
id="btnInsert"
Text="Add Comments"
CommandName="Insert"
Runat="server" />
</InsertItemTemplate>
</asp:FormView>
<hr />
<asp:GridView
id="grdGuestBook"
DataSourceID="srcGuestBook"
Runat="server" />
<asp:SqlDataSource
id="srcGuestBook"
SelectCommand="SELECT Name,Comments,EntryDate
FROM GuestBook ORDER BY Id DESC"
InsertCommand="INSERT GuestBook (Name,Comments)
VALUES (@Name,@Comments)"
ConnectionString="<%$ ConnectionStrings:GuestBook %>"
Runat="server" OnInserting="srcGuestBook_Inserting" />
</div>
</form>
</body>
</html>
此代码供LZ参考
<%@ Import Namespace="System.Data.SqlClient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
Protected void sreGuestBook_Inserting(object sender,SqlDataSourceCommandEventArgs e)
{
e.Command,Parameters.Add(new SqlParameter("@Name",User.Identity.Name));
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Show ProfileParameter</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FormView
id="frmGuestBook"
DataSourceID="srcGuestBook"
DefaultMode="Insert"
Runat="server">
<InsertItemTemplate>
<asp:Label
id="lblComments"
Text="Enter Your Comments:"
Runat="server" />
<br />
<asp:TextBox
id="txtComments"
Text='<%# Bind("Comments") %>'
TextMode="MultiLine"
Columns="50"
Rows="4"
Runat="server" />
<br />
<asp:Button
id="btnInsert"
Text="Add Comments"
CommandName="Insert"
Runat="server" />
</InsertItemTemplate>
</asp:FormView>
<hr />
<asp:GridView
id="grdGuestBook"
DataSourceID="srcGuestBook"
Runat="server" />
<asp:SqlDataSource
id="srcGuestBook"
SelectCommand="SELECT Name,Comments,EntryDate
FROM GuestBook ORDER BY Id DESC"
InsertCommand="INSERT GuestBook (Name,Comments)
VALUES (@Name,@Comments)"
ConnectionString="<%$ ConnectionStrings:GuestBook %>"
Runat="server" OnInserting="srcGuestBook_Inserting" />
</div>
</form>
</body>
</html>
此代码供LZ参考
#12
可能是你的其他類文件有問題吧。
#13
曾经遇到过这样的问题,原因还是CodeFile="Login_Person.aspx.cs" Inherits="Login_Person" 没有关联上,去看下".cs文件里的类名是否跟aspx的Inherits一样,或者干脆把Inherits="Login_Person删除。
我当时遇到的情况是我复制了一份文件,也就是文件夹下有2个Login_Person.aspx和Login_Person.aspx.cs,是因我在修改是复制了一份,另一分叫复件Login_Person.aspx和复件Login_Person.aspx.cs,虽然文件名不一样,但是两个文件的Inherits一样,里面内容一样,所以在vs2005里编译运行时候可以,但写代码的时候提示找不到页面里的元素,把后者删除就可以了!不知道你有没有这种情况。
其他问题就不知道了,知道了在来回!
我当时遇到的情况是我复制了一份文件,也就是文件夹下有2个Login_Person.aspx和Login_Person.aspx.cs,是因我在修改是复制了一份,另一分叫复件Login_Person.aspx和复件Login_Person.aspx.cs,虽然文件名不一样,但是两个文件的Inherits一样,里面内容一样,所以在vs2005里编译运行时候可以,但写代码的时候提示找不到页面里的元素,把后者删除就可以了!不知道你有没有这种情况。
其他问题就不知道了,知道了在来回!
#14
aspx文件 Inherits="Login_Person"
.cs文件 public partial class Login_Person : System.Web.UI.Page{}
两个地方有没有对应上啊?
#15
另外推荐LZ多使用学习div+css布置表示层页面
#16
多谢Phper2008 按照你的说法我的问题解决了,
真是十分感谢Sorm531590401 不停的支持,都是在新建项目懒省劲,拷贝代码惹得祸!
接分!
真是十分感谢Sorm531590401 不停的支持,都是在新建项目懒省劲,拷贝代码惹得祸!
接分!
#17
呵呵,我也是好久没有来csdn了,今天偶尔来一下,当然得要认真回复喽:)
加油!LZ!
加油!LZ!