Using Javascript confirm box in Asp.net
-
hi, i m writing thr following code to pop up the confirmation box in Asp.net. i do not want to write a function in html file and call it in code behind using button.attribute.Add . I want to write all the code in code behind file.If the user chooses YES then something is done else the code after that is not executed if(Button11.text=="sandeep") { string strScript= ""; strScript = ""; strScript = strScript + "function confirmReject(){"; strScript = strScript + "if (confirm('Are you sure to perform this action?')==true)"; strScript = strScript + "{return true;}"; strScript = strScript + "else"; strScript = strScript + "{return false;}}"; strScript = strScript + ""; ClientScript.RegisterStartupScript(typeof(Page), "ClientScript", strScript); TextBox1.text="you are Rejected"; } This is not working . waiting reply sandeep
-
hi, i m writing thr following code to pop up the confirmation box in Asp.net. i do not want to write a function in html file and call it in code behind using button.attribute.Add . I want to write all the code in code behind file.If the user chooses YES then something is done else the code after that is not executed if(Button11.text=="sandeep") { string strScript= ""; strScript = ""; strScript = strScript + "function confirmReject(){"; strScript = strScript + "if (confirm('Are you sure to perform this action?')==true)"; strScript = strScript + "{return true;}"; strScript = strScript + "else"; strScript = strScript + "{return false;}}"; strScript = strScript + ""; ClientScript.RegisterStartupScript(typeof(Page), "ClientScript", strScript); TextBox1.text="you are Rejected"; } This is not working . waiting reply sandeep
you can write code below in code behind Page_Load() { if(!ispostback) { button.attribute.Add("onclick","return confirm('Are you sure to perform this action?');") } } if this button click first confirm execute and if select OK the code behind of button execute. bye
-
hi, i m writing thr following code to pop up the confirmation box in Asp.net. i do not want to write a function in html file and call it in code behind using button.attribute.Add . I want to write all the code in code behind file.If the user chooses YES then something is done else the code after that is not executed if(Button11.text=="sandeep") { string strScript= ""; strScript = ""; strScript = strScript + "function confirmReject(){"; strScript = strScript + "if (confirm('Are you sure to perform this action?')==true)"; strScript = strScript + "{return true;}"; strScript = strScript + "else"; strScript = strScript + "{return false;}}"; strScript = strScript + ""; ClientScript.RegisterStartupScript(typeof(Page), "ClientScript", strScript); TextBox1.text="you are Rejected"; } This is not working . waiting reply sandeep
see this what i have done... Button1.Attributes.Add("onclick","javascript:return confirmReject();"); string strScript= ""; strScript = ""; strScript = strScript + "function confirmReject(){"; strScript = strScript + "if (confirm('Are you sure to perform this?')==true)"; strScript = strScript + "{return true;}"; strScript = strScript + "else"; strScript = strScript + "{return false;}}"; strScript = strScript + ""; Response.Write(strScript); i have this code in pageload only...and it's working fine... i hope this will help u out Thanx Anuj Kamthan Software Developer Solversa Technologies, Pune - 411007, India. http://www.solversa.com -- modified at 6:22 Monday 22nd May, 2006