未将对象引用设置到对象的实例。修改密码就出现这个有关问题
未将对象引用设置到对象的实例。修改密码就出现这个问题
asp-net
using System;
using System.Data;
using System.Configuration;
using System.Collections;
public partial class XueShengMod : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (this.TextBox2.Text == "" || this.TextBox3.Text == "")
{
Response.Write("alert('密码不能为空!');document.location=document.location;");
}
if
(this.TextBox1.Text!=Session["PWD"].ToString())
{
Response.Write("alert('旧密码不对!');document.location=document.location;");
}
else if (this.TextBox2.Text == this.TextBox3.Text)
{
string sql = "update TB_XueSheng set PassWord='" + this.TextBox2.Text + "' where XueHao='" + Session["username"].ToString() + "'";
bool b = DBHelper.ExecSql(sql);
if (b)
{
未将对象引用设置到对象的实例。
源错误:
行 22: Response.Write("alert('密码不能为空!');document.location=document.location;");
行 23: }
行 24: if
行 25: (this.TextBox1.Text!=Session["PWD"].ToString())
行 26: {
------解决思路----------------------
Session["PWD"]没值……你的赋值在哪里?
------解决思路----------------------
应该在你的登录页面有这样一句,
在登录验证成功后,
session["userName"]=用户名;
session["pwd"]=密码;
asp-net
using System;
using System.Data;
using System.Configuration;
using System.Collections;
public partial class XueShengMod : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (this.TextBox2.Text == "" || this.TextBox3.Text == "")
{
Response.Write("alert('密码不能为空!');document.location=document.location;");
}
if
(this.TextBox1.Text!=Session["PWD"].ToString())
{
Response.Write("alert('旧密码不对!');document.location=document.location;");
}
else if (this.TextBox2.Text == this.TextBox3.Text)
{
string sql = "update TB_XueSheng set PassWord='" + this.TextBox2.Text + "' where XueHao='" + Session["username"].ToString() + "'";
bool b = DBHelper.ExecSql(sql);
if (b)
{
未将对象引用设置到对象的实例。
源错误:
行 22: Response.Write("alert('密码不能为空!');document.location=document.location;");
行 23: }
行 24: if
行 25: (this.TextBox1.Text!=Session["PWD"].ToString())
行 26: {
------解决思路----------------------
Session["PWD"]没值……你的赋值在哪里?
------解决思路----------------------
应该在你的登录页面有这样一句,
在登录验证成功后,
session["userName"]=用户名;
session["pwd"]=密码;