【发布时间】:2017-04-25 03:19:52
【问题描述】:
我目前正在通过 Visual Studio C# 语言开发一个网站,现在我正在设计用户密码重置页面。我遇到的问题是我想通过使用基本的textbox.text = ""; 方法将控件添加到textboxes 和labels。但它一直告诉我它不存在。我已经搜索了很多解决方案,我确信:
1、标签名与编码名同名。
2, 没有其他同名页面,因为我重新创建了另一个不同名称的页面。
3,所有这些都添加了:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Mail;
using System.Drawing;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.Text;
using System.IO;
有人可以帮忙吗?我已经在这里困惑了几天了:)
protected void SubmitButton_Click(object sender, EventArgs e)
{
string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
SqlCommand cmd = new SqlCommand("spResetPassword", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter paramUsername = new SqlParameter("@UserName", userTextBox.text);
cmd.Parameters.Add(paramUsername);
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
if (Convert.ToBoolean(rdr["ReaturnCode"]))
{
SendPasswordResetEmail(rdr["Email"].ToString(), TextBox1.Text, rdr["UniqueId"].ToString());
msgLabel.Text = "An reset password Email has sent to your Email address.";
}
else
{
msgLabel.Text = "username not found!";
}
}
}
【问题讨论】:
-
表示所有userTextBox、msgLabel都显示在当前上下文中不存在
-
由于所有分配的服务器控件未绑定在代码隐藏中,请检查.designer.aspx.cs中的类名是否与.aspx.cs完全匹配,然后确保引用的代码隐藏文件ASPX 页面中的名称相同。
-
我以为 textbox1 有一个小写的 t,“textBox1.Text”
-
你有html吗?
-
命名空间 testSiteV1.Account { public partial class ForgetPsw { ///
/// PassRecover 控制。 /// ////// 自动生成的字段。 /// 修改从设计器文件到代码隐藏文件的移动字段声明。 /// protected global::System.Web.UI.WebControls.PasswordRecovery PassRecover; } }
标签: c# asp.net .net visual-studio