如何清除asp.net中的按钮单击计数? [英] ho can clear the button click count in asp.net?

查看:68
本文介绍了如何清除asp.net中的按钮单击计数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void Button1_Click(object sender, EventArgs e)
   {   count++;
       int noofcount = count;
       Label6.Text = noofcount.ToString();
       if (noofcount > 5)
       {    string ch = "Attacker";

           
                     con = new SqlConnection("Data Source=Database; Initial Catalog=firecol; User Id=sa; Pwd=password");
           con.Open();

           cmd = new SqlCommand("update normaluser set type='" + ch + "' where username='" + Label5.Text + "'", con);
           cmd.ExecuteNonQuery();
           con.Close();
           count=0;
       }
       else
 {String bl = "", la = "";
           con = new SqlConnection("Data Source=FABSYS39\\SQLEXPRESS; Initial Catalog=firecol; User Id=sa; Pwd=saadmin");

           con.Open();
 cmd = new SqlCommand("Insert into questions Values('" + Label5.Text + "','" + ddldetails.SelectedItem.Text + "','" + DropDownList2.SelectedItem.Text + "','" + TextBox1.Text + "','" + la + "','" + bl + "')", con);
           cmd.ExecuteNonQuery();
           con.Close();
           Label4.Visible = true;
       }




我要在离开此页面时清除此按钮的提示计数....如何清除该内容???请帮助我???




i wanna clear this button clcik count while i leaving in this page....how can i clear that??? pls help me???

推荐答案

您可以保留一个标志,指示您要重置.然后在页面加载事件中检查IsPostBack,如果不正确,则不是,如果您的标志建议您重置计数,请重置它.

等一下,为什么要公开打开您的SQL Server名称,ID和密码?

你不怕!!!

Milind
You can keep a flag that indicates you to reset. Then In the page load event check IsPostBack, if it is not true, not if your flag suggests you to reset count, reset it.

Wait a minute, Why are you giving your SQL server name, id, password in open?

Are you not scared !!!

Milind


这篇关于如何清除asp.net中的按钮单击计数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆