473,386 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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.attributes.add("onclick",
javascript:__dopostback('','');) ?

Thanks

Tuomo
Feb 18 '08 #1
5 1525
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********@gmail.comwrote in message
news:ac**********************************@v3g2000h sc.googlegroups.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.attributes.add("onclick",
javascript:__dopostback('','');) ?

Thanks

Tuomo

Feb 18 '08 #2
On 18 helmi, 17:38, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
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********@gmail.comwrote in message
news:da**********************************@64g2000h sw.googlegroups.com...
On 18 helmi, 17:38, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
>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"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
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.ClientScript.RegisterClientScriptBlock() and
Page.ClientScript.GetCallbackEventReference()....

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

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

Similar topics

4
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...
3
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
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...
2
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...
3
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...
19
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...
6
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...
2
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...
3
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...

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.