我的手风琴窗格中有一个按钮,它生成随机密码并将数据插入数据库。但它不起作用,即使我在不去点击事件的情况下调试控件。我的 HTML 代码我是新用户
<asp:Button ID="genrate" runat="server" Text="Genrate passwords" />
</Content>
</asp:AccordionPane></b>
后面的代码是--- public static string RandomStr()
{
string rStr = Path.GetRandomFileName();
rStr = rStr.Replace(".", ""); // For Removing the .
return rStr;
}
protected void genrate_Click1(object sender, EventArgs e)
{
string rand = RandomStr();
un.Text = rand;
Uname.ReadOnly = true;
string str = ConfigurationManager.ConnectionStrings["ajax"].ConnectionString;
string selectcomnd = "INSERT INTO user (username,password) as value(@e1,@e2)";
SqlCommand cmd = new SqlCommand();
SqlConnection con = new SqlConnection(str);
con.Open();
cmd.CommandText = selectcomnd;
cmd.Parameters.Add("@e1", SqlDbType.NChar).Value = Uname.Text;
cmd.Parameters.Add("@e2", SqlDbType.NChar).Value = rand;
con.Close();
}
提前致谢