How to make a button to have both server side and client event in ASP.NET?

L

Lau Alvin

HI all ,

I want to make a button which have a server side OnClick event in .cs to
update the DB. But I want it to have a client side onclick event to run
a javascript popup too. And the javascript will be run only in some
conditions determine by the input of some webcontrols. Finally the
server side event will depend on the chioce of user in the javascript
popup.

How can i achieve it ?

thX ~
 
M

Mark Rae

I want to make a button which have a server side OnClick event in .cs to
update the DB. But I want it to have a client side onclick event to run
a javascript popup too. And the javascript will be run only in some
conditions determine by the input of some webcontrols. Finally the
server side event will depend on the chioce of user in the javascript
popup.

How can i achieve it ?

I think you're trying to make life difficult for yourself! I would suggest:

1) The button calls a client-side JavaScript function which loads the popup.

2) The user makes whatever choices you require in the popup then click an OK
button when finished.

3) The OK button in the popup calls a server-side function (or just
submits!) which updates the database and closes the popup.
 
K

Karl

btnId.Attributes.Add("onclick", "ClientSideFunctionName();") and the normal
way for server-side.

Karl
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top