C# 清除文本字段的简单任务
我试图在数据发布后清除两个文本字段。该页面发回,但不删除文本字段C# 清除文本字段的简单任务,c#,postback,C#,Postback,我试图在数据发布后清除两个文本字段。该页面发回,但不删除文本字段 txtComment.Text = ""; txtEmail.Text = ""; 如何修复下面的代码 protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["PicID"] != null) { int vPicID = Convert.ToInt32(Requ
txtComment.Text = "";
txtEmail.Text = "";
如何修复下面的代码
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["PicID"] != null)
{
int vPicID = Convert.ToInt32(Request.QueryString["PicID"]);
BSComments DTGetComments = new BSComments();
DataTable DTGetCommentsbyID = DTGetComments.GetCommentsByPicIDs(vPicID);
//Create User object
// GetMemberInfo GetMember = new GetMemberInfo();
// DataTable DAMemberInfo = GetMember.GetmemberInfo(UserID);
txtComment.Text = "";
txtEmail.Text = "";
}
}
protected void Button1_Click(object sender, EventArgs e)
{
//Check to see if the Email has an account
BSComments CheckIFmember = new BSComments();
DataTable DAMemberInfo = CheckIFmember.CheckIFMemberReturnNameEmail(txtEmail.Text);
int picid =Convert.ToInt32(Request.QueryString["PicID"]);
if (DAMemberInfo.Rows.Count > 0)
{
String myGuid = "";
String MemberName = "";
foreach (DataRow row in DAMemberInfo.Rows)
{
myGuid = row["Guid"].ToString();
MemberName = row["MemberName"].ToString();
}
BSComments InstertComments = new BSComments();
InstertComments.InserComment(picid, txtEmail.Text, txtComment.Text, MemberName, myGuid);
txtComment.Text = "";
txtEmail.Text = "";
}
else
{
txtComment.Text = "You need to have an account to post.";
}
txtComment.Text = "";
txtEmail.Text = "";
}
}
如果您已逐步检查代码,以确定txtcoment和txtmail字段实际上已将其.Text值设置为String.Empty,那么我建议您的代码中可能根本没有问题 查看浏览器是否“有帮助地”为您预先填充这些字段。如果是这样,您可以在这些控件的aspx文件中为
AutoComplete=“off”
例如:
<asp:TextBox runat="server" id="txtComment" AutoComplete="off" />
同意,其他要做的事情是使用fiddler(www.fiddler2.org)检查服务器发送到浏览器的内容。@KenHenderson:是的。尽管页面上的一个简单视图源也可以工作。