T
Tony Baker
Wow. I finally found out the easiest way to display a yes/no (well,
yes/cancel) dialog pop up from ASP.Net.
Turnes out to be really easy. Just add the following in you Page_Load
method (C# code behind):
if(!IsPostBack)
{
DeleteUserBtn.Attributes.Add("onclick", "return confirm('Are you sure
you want to Delete?')");
}
Replace DeleteUserBtn with the name of your asp.net button (or
whatever control you want).
This will assign javaScript to that button to return the result of
displaying the confirm dialog. If user clicks yes, then it returns
true and the buttons code-behind method will be called. Otherwise a
post-back won't occur and the code-behind will not be run!!
This method can be used to call any javaScript function you may have
already defined.
I hope someone can find this info useful and it saves someone some
time.
Tony.
P.S. If you are writing an ASP.Net program and you don't know
JavaScript, you are limiting yourself a lot! Spend an 30 mins or so
doing this tutorial to give yourself some idea of the power it can
provide:
http://www.w3schools.com/js/default.asp
yes/cancel) dialog pop up from ASP.Net.
Turnes out to be really easy. Just add the following in you Page_Load
method (C# code behind):
if(!IsPostBack)
{
DeleteUserBtn.Attributes.Add("onclick", "return confirm('Are you sure
you want to Delete?')");
}
Replace DeleteUserBtn with the name of your asp.net button (or
whatever control you want).
This will assign javaScript to that button to return the result of
displaying the confirm dialog. If user clicks yes, then it returns
true and the buttons code-behind method will be called. Otherwise a
post-back won't occur and the code-behind will not be run!!
This method can be used to call any javaScript function you may have
already defined.
I hope someone can find this info useful and it saves someone some
time.
Tony.
P.S. If you are writing an ASP.Net program and you don't know
JavaScript, you are limiting yourself a lot! Spend an 30 mins or so
doing this tutorial to give yourself some idea of the power it can
provide:
http://www.w3schools.com/js/default.asp