How to fire a server side function from client side

V

Vili

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
 
V

Vili

What you describe is called "server-side events". All you need is to setup
OnClick events for your buttons.

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
 
E

Eliyahu Goldin

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 said:
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
 
V

Vili

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
 

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

No members online now.

Forum statistics

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

Latest Threads

Top