Clint side and server side event

W

WilsonSmith

Hello All,

My development environment is as follows:

ASP.Net App with .Net Framework 1.1 with VB.net



I have added the code in the page load event for non post back activity.

MyButton.Attributes("onclick") = "javascript:return confirm('You
will loose all data. Do you want to continue?');"

When the user clicks on MyButton and chose "Cancel" button, still the
MyButton clicked event is getting called at the server side. I want to call
this server side code only when the user selects OK button.

What is wrong in the code?

Wilson
 
B

Bobby Ryzhy

Get rid of the server side event - and do a Form.submit on the if(confirm)



Hello All,

My development environment is as follows:

ASP.Net App with .Net Framework 1.1 with VB.net



I have added the code in the page load event for non post back activity.

MyButton.Attributes("onclick") = "javascript:return confirm('You
will loose all data. Do you want to continue?');"

When the user clicks on MyButton and chose "Cancel" button, still the
MyButton clicked event is getting called at the server side. I want to call
this server side code only when the user selects OK button.

What is wrong in the code?

Wilson

Bobby Ryzhy
bobby @ domain below
http://weekendtech.net
 
S

Steve C. Orr [MVP, MCSD]

This syntax works for me:
btn.Attributes.Add("OnClick","return confirm('Delete?');")
 
W

WilsonSmith

Same code is not working for me.

Somehow the page is getting resubmitted when the user selects OK or Cancel
button.

My code was like this

btn.Attributes.Add("OnClick","return confirm('Delete?');")

Today I am noticing it is not working.

I don't know why?

Wilson.
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top