default.aspx
<%@ Register TagPrefix="aspcn" TagName="Footer" Src="Footer.ascx" %>
<html >
<head runat="server">
<title>4.修改某一用户的密码</title>
</head>
<body>
<form id="form1" runat="server">
<aspcn:Footer runat="server" id="footer1" /><br />
</form>
</body>
</html>
footer.ascx
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script language="C#" runat="server" >
protected string strConnString = "Data Source=127.0.0.1;uid=sa;pwd=;Initial Catalog=SY2040570庄文鹏";
void bt_Submit(object serder, EventArgs e)
{
string getUserID, getUserPsd, chUserPsd, strselect;
getUserID = tUserID.Text;
getUserPsd=tPassWord.Text;
chUserPsd=nPassWord1;
strselect = "update user_info set user_password='" + chUserPsd + "'" + "where user_userid='" + getUserID + "' and user_password='" + getUserPsd + "'";
SqlConnection sqlconn = new SqlConnection(strConnString);
SqlCommand sqlcomm = new SqlCommand(strselect, sqlconn);
SqlDataReader dr = sqlcomm.ExecuteReader();
if (dr.Read())
{
if (nPassWord1.Text == nPassWord2.Text)
{
labContent.Text = "密码修改成功";
}
else
{
labContent.Text = "两次输入的密码不一致";
}
}
else
{
labContent.Text = "用户名和密码错误";
}
sqlconn.Close();
sqlconn = null;
}
</script>
<table cellpadding="0" cellspacing="0" border="1" id="TABLE1" onclick="return TABLE1_onclick()" >
<tr>
<td colspan="2">输入要修改的用户ID和密码</td>
</tr>
<tr>
<td align="right" >用户ID</td>
<td style="width: 192px"><asp:TextBox ID="tUserID" runat="server" Width="135px" /></td>
</tr>
<tr>
<td align="right" >旧密码确认</td>
<td style="width: 192px"><asp:TextBox ID="tPassWord" runat="server" TextMode="password" Width="135px" /></td>
</tr>
<tr>
<td align="right" >新密码</td>
<td style="width: 192px"><asp:TextBox ID="nPassWord1" runat="server" TextMode="password" Width="135px" /></td>
</tr>
<tr>
<td align="right" >新密码确认</td>
<td style="width: 192px"><asp:TextBox ID="nPawwWord2" runat="server" TextMode="password" Width="134px" /></td>
</tr>
<tr>
<td> </td>
<td ><asp:Button ID="busubmit" runat="server" Text="更新" OnClick="bt_Submit" />
<input type="reset" id="bnreset" value="清除"/> </td>
</tr>
<tr>
<td colspan="2" align="center" ><asp:Label ID="labContent" runat="server" /></td>
</tr>
</table>
编译器错误信息: CS0029: 无法将类型“System.Web.UI.WebControls.TextBox”隐式转换为“string”
实在找不到这小不点的问题在哪里了
[此贴子已经被作者于2007-4-28 19:41:19编辑过]