在asp.net中显示消息框消息、asp、net

2023-09-03 01:30:00 作者:是狗总该滚走

有关显示在sucessfull消息框保存的任何项目我想显示消息框。

For displaying message box on sucessfull save of any item i wanted to show messagebox.

我GOOGLE了它,并尝试不同的codeS,但没有一次成功。

I googled it and tried different codes but none of them worked.

目前我code为:

 try
 {
     con.Open();
     string pass="abc";
     cmd = new SqlCommand("insert into register values('" + txtName.Text + "','" + txtEmail.Text + "','" + txtPhoneNumber.Text + "','" + ddlUserType.SelectedText + "','" + pass + "')", con);
     cmd.ExecuteNonQuery();
     con.Close();
     Response.Write("<script LANGUAGE='JavaScript' >alert('Login Successful')</script>");
}
catch (Exception ex)
{

}
finally
{
    con.Close();
}

它不工作。请我的GUID的消息框code。 我使用Mozilla浏览器。

Its not working. Kindly guid me with the messagebox code. I am using Mozilla browser.

推荐答案

@freelancer如果你正在使用的ScriptManager那就试试这个code消息。

@freelancer If you are using ScriptManager then try this code for message..

string script = "alert(\"Hello!\");";
ScriptManager.RegisterStartupScript(this, GetType(), 
                      "ServerControlScript", script, true);