473,670 Members | 2,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to fire a server side function from client side

Hi all

I am having a problem here

Is it possible to fire a server side function from client side?

ie. I have a function on codebehind

Sub DoSomething(o as object)

'do something to o

End sub

and on button press I dynamically create few linkbuttons (or something
else if needed) and for each linkbuttons I would need to launch the
DoSomething function from codebehind?

I have read that with javascript __doPostback it would be possible but
have no idea how to.

Something like mybutton.attrib utes.add("oncli ck",
javascript:__do postback('','') ;) ?

Thanks

Tuomo
Feb 18 '08 #1
5 1537
What you describe is called "server-side events". All you need is to setup
OnClick events for your buttons.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Vili" <vi********@gma il.comwrote in message
news:ac******** *************** ***********@v3g 2000hsc.googleg roups.com...
Hi all

I am having a problem here

Is it possible to fire a server side function from client side?

ie. I have a function on codebehind

Sub DoSomething(o as object)

'do something to o

End sub

and on button press I dynamically create few linkbuttons (or something
else if needed) and for each linkbuttons I would need to launch the
DoSomething function from codebehind?

I have read that with javascript __doPostback it would be possible but
have no idea how to.

Something like mybutton.attrib utes.add("oncli ck",
javascript:__do postback('','') ;) ?

Thanks

Tuomo

Feb 18 '08 #2
On 18 helmi, 17:38, "Eliyahu Goldin"
<REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
What you describe is called "server-side events". All you need is to setup
OnClick events for your buttons.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
The problem is the dynamic controls. They get no events when clicked
on. If I could create them in page_init I could add event handel
but at the init I have no idea what buttons will be created

Tuomo
Feb 19 '08 #3
It is very rear when you really need to create controls in code. The proper
way is to put them in an item template of a databound control and databind
the control in run-time. Then you can setup all the events in the template.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Vili" <vi********@gma il.comwrote in message
news:da******** *************** ***********@64g 2000hsw.googleg roups.com...
On 18 helmi, 17:38, "Eliyahu Goldin"
<REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
>What you describe is called "server-side events". All you need is to
setup
OnClick events for your buttons.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP
[ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net

The problem is the dynamic controls. They get no events when clicked
on. If I could create them in page_init I could add event handel
but at the init I have no idea what buttons will be created

Tuomo

Feb 19 '08 #4
On 19 helmi, 11:03, "Eliyahu Goldin"
<REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
It is very rear when you really need to create controls in code. The proper
way is to put them in an item template of a databound control and databind
the control in run-time. Then you can setup all the events in the template.
True! I just realised that I might have been able to use repeater on
this to make the same thing I am trying to do now

Thank you all for your answers. I was too focused on getting the
serverside event fired from javascript to see that there
might be a better solution.

Tuomo
Feb 19 '08 #5
another way of doing this - is to use
Page.ClientScri pt.RegisterClie ntScriptBlock() and
Page.ClientScri pt.GetCallbackE ventReference() ....

.... more at <a href="http://www.siccolo.com/articles.asp">S iccolo
Articles</a>
Feb 19 '08 #6

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

Similar topics

4
10141
by: usl2222 | last post by:
Hi folks, I appreciate any assistance in the following problem: I have a form with a bunch of dynamic controls on it. All the controls are dynamically generated on a server, including all the validators. The user enters the data, presses OK. My OK button is dynamically generated as well, with some code-behind logic in
3
2073
by: Ant | last post by:
I'm building a Web user control that has several public functions. Can I fire them from the client side? for example Javascript and an HTML button
2
1678
by: Curtis Kam | last post by:
Dear all, I'm now using TCP socket using user-defined protocol to communicate between two machines (server and client). But now, I'd like to introduce a Web Service in my server-side. If my client software subscribes the web service, does it have the flexibilty to fire a event to server? That is, is there any similar function just like DCOM (they can fire event to each other and remote function call)? Thanks in advance.
2
2652
by: Stuart Whiteford | last post by:
Hi, I asked this back in January without answer and forgot about it until now. I've got a basic web form, two textboxes, a couple of radio button groups, some required field validators, and a Submit and Cancel button. When the page loads, if I click the Cancel button, the server-side event fires as normal.
3
4751
by: rfinch | last post by:
I'm trying to pass two values from client script (Javascript) to the code-behind for a page using three hidden fields - two to hold the values and a third to fire the ValueChanged event. I have tried every method I can think of to get the event to fire, but it will not, so either I am missing some code or am misunderstanding the nature of the event. If anyone can review the test code posted below (which I created to try to debug the...
19
4751
by: Daniela Roman | last post by:
Hello, I try to fire an event under a button click event and maybe anybody can give a clue please. I have let's say a WEB grid with PageIndexChanged event: private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
6
2360
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
2
3910
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite well, so at times it is tempting just to port parts of it over mostly as-is. In fact, one MSDN article I read suggested using straight HTML wherever possible to make the app more efficient and less resource demanding. On one page there are 2...
3
2805
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I need to control the visibility of a textbox based on a dropdown selection in the datalist's edititem template. To do this, I registered a client script block function and attached a client side handler for the dropdownlist's onchange event in the...
0
8901
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
8813
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
8591
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7412
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6212
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
5683
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
4388
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2799
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
2037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.