How to handle Cancel button in Confirm() method?

L

lakshmikandhan

Hi All,

Can anyone tell how to handle the Cancel button in the
JavaScript Confirm() method?If we press cancel, I have to perform
certain action in the Server side? Plz help me!!

Thanx,
Jacob.
 
L

lakshmikandhan

Hi Eliyahu,

Thanx for ur response.Can u explain the above concept by an
simple example??? Plz give me some code samples!!
 
E

Eliyahu Goldin

Jacob,

Cancel button click causes the confirm dialog to close with return value
false. All this is taking place on client-side. You will need to communicate
an info to the server side. Most standard way of doing this is using hidden
input elements. You can cause the page to postback from JavaScript by
calling the form's submit() method.

Eliyahu
 
E

Eliyahu Goldin

on client:
if(!confirm("...")){
myForm..value="CANCELED";
myForm.submit();
}

in .aspx file:
<input type=hidden id=inhMessage runat=server>

in the code-behind (c#):
in the Page_Load event:
if (IsPostBack())
{
if (this.inhMessage.Value == CANCELED")
{
// do something
}
}

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top