Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 清除文本字段的简单任务_C#_Postback - Fatal编程技术网

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:是的。尽管页面上的一个简单视图源也可以工作。