473,811 Members | 2,911 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 ~

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
4 1623
"Lau Alvin" <cl****@ie.cuhk .edu.hk> wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. .
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.
Nov 18 '05 #2
Lau,

See if this article helps.

http://www.developerfusion.com/show/4505/

Alan
"Lau Alvin" <cl****@ie.cuhk .edu.hk> wrote in message
news:#P******** *****@TK2MSFTNG P10.phx.gbl...
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 ~

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #3

Thx All ~
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4
btnId.Attribute s.Add("onclick" , "ClientSideFunc tionName();") and the normal
way for server-side.

Karl

"Lau Alvin Lau" <cl****@ie.cuhk .edu.hk> wrote in message
news:Ol******** *****@tk2msftng p13.phx.gbl...

Thx All ~
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4805
by: yfng | last post by:
In a web form, I want the user clicks on one button and this button will trigger another button/link which will open a new browser window? How to do that? Is there any method like Button.performclick? Thanks
2
1475
by: Yama | last post by:
Hi, I have a button which is a server-side control. If a client-side error on a form is produced and a javascript (client-side) is fired how do I avoid the server-side button_client event to occur? (that is because the page gets refreshed for no reason even if I say do nothing) Thank you, Yama
7
2826
by: IntraRELY | last post by:
I am using the following command to launch and .NET VB Executable, which is a simple Windows Form (printCheckClient.exe). I am using a HyperLink Control and works perfect. hlPrintChecks.NavigateUrl = "javascript:var newWindow =window.open('printCheckClient.exe', 1,'height=350,width=350,menubar=no,status=no,toolbar=no')" I want to use a standard ASP.NET Button, but not sure what method to use. Is there a way to accomplish this. I may not...
1
2924
by: Bin Song, MCP | last post by:
Hi all I got a strange problem In my webform, I have a server-side Button "btnDisable" to save some data and enable or disable all other fields in this form based on the data. The logic is: on server click event, save data, write a client-side script to set 'ynDisable' to true or false, and then use general client-side code in window's onload event to disable all fields. The code is function disableFields( with (window.document var...
5
8007
by: TS | last post by:
for some reason, it posts to the server, but no click events of any buttons on form fire. the button is the first one on the form. when the focus is inside the textbox, it doesnt' work. if i click the form, it works fine. how do i make it fire the click event of this button? (i have it on a diff. page and it works fine...can't figure out why it is diff. here) thanks to all! (i tried tab order)
3
2478
by: wardy1975 | last post by:
Hi all....looking for a bit of help here....I'm using an asp.net server side button, and trying to add an onclick event on the button to call a javascript function. However, I am trying to enter the onclick syntax directly in the html instead of via the attributes.add functionality (this is required due to the dynamic nature of how the buttons are added to the screen). The problem is, I get a compilation error when I try to load the page...
11
4257
by: bill | last post by:
I dynamically create buttons and associate them with an event using AddHandler. I want all the button events to fire at one time, when the page is posted, instead of when each button is clicked. How I stop the buttons from posting back when they are clicked? Thanks
2
2086
by: moondaddy | last post by:
I have an asp.net 2.0 application and put a html button on a web page. I double clicked on the button and it crated the event handler for me and created the stub js function for it like this: <input id="btnQryFunctions" type="button" value="Query Functions" language="javascript" onclick="return btnQryFunctions_onclick()" /> and the function it created was: function btnQryFunctions_onclick() {
6
2368
by: erdos | last post by:
I have an asp.net 2.0 button with server and client side click events. On the first click, both events will fire. On the next click, only the client side event fires. How do I make the server side event not fire after the first click? Thanks, Brett
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10651
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10392
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6893
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5693
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4341
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3868
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3020
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.