I think that you should place the code that is now in cmdSubmit_Click in the Page_Load like this:
http://msdn.microsoft.com/en-us/library/ms178207.aspx[
^]
and then
public void cmdSubmit_Click(object sender, EventArgs e)
{
lblMessage.Text = "";
}
void Page_Load(object sender, EventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script type = 'text/javascript' language = "'javascript'">");
sb.Append("DoubleBookingPopUp()");
sb.Append("</script>");
if (!ClientScript.IsClientScriptBlockRegistered("exampleScript"))
ClientScript.RegisterStartupScript(this.GetType(), "exampleScript",
sb.ToString());
cmdSubmit.Attributes.Add("onclick", "DoubleBookingPopUp();");
}
Or a simpler version of this would be:
void Page_Load(object sender, EventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script type = 'text/javascript' language = "'javascript'">");
sb.Append("DoubleBookingPopUp()");
sb.Append("</script>");
cmdSubmit.Attributes.Add("onclick", sb.ToString());
}
But your function would have to return true (if you want to submit) or false (if you don't want to submit).
But I see that you already do __doPostBack, so that would not be necessary I think.