Hi,
I have a button click event handler in which i have embedded a javascript code for generating a confirmation box.
Based on the selection in the confirmation box a change is to be made in a hidden field having id hdnField.
In the same btnSubmit_Click() i have a conditional statement written.
Inside the conditional statement i have written a code to make some changes to the page displayed.
All was working fine until I embedde the JavaScript code.
Now after i wrote the script i am facing a problem.
The changes made in the page (which is written inside the conditional statement) is getting displayed only on the second click on the submit button .
Could some one help me to sort this out.
I am pasting the code here.
private void btnSubmit_Click(object sender, System.EventArgs e)
{
Response.Write("<script language=javascript>alert('Clicked on button submit')</script>");
strJavaScript += "\n<script language='javascript' id='confirmJS'>\n";
strJavaScript += " if(confirm( 'Do you want to continue ? ')) {\n";
strJavaScript += "var objForm = document.forms;\n";
strJavaScript += "var objFormField = objForm.elements;\n";
strJavaScript += " objFormField.value='1';}\n";
strJavaScript +="</script>";
this.RegisterStartupScript("confirmJS",strJavaScript);
Response.Write(hdnField.Value.ToString());
if(hdnField.Value.Equals(1.ToString()))
{
btnSubmit.Enabled = false;
if(PlaceHolder2.HasControls())
{
foreach(Control c in PlaceHolder2.Controls)
{
/* Got some code here which deals with changes to controls inplace Holder
}
}
}
}