Freelancer Freelancer - 4 months ago 31
Javascript Question

display messagebox in asp.net

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

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

Currently my code is:

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();
}


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

Answer

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

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