Javascript function with value of server-side event

T

timor.super

Hi group,

what I would like to do is maybe a little hard and I can't achieve to
make it. So I need your help to go in the right way.

What I want is to create a webcontrol that can use one its properties
value , set with the server-sider onclick event, with client
javascript.

Something like this :

(default.apsx)
<mycontrol:mycontrol runat="server" id="testControl"
OnServerClick="ClickEvent"/>

(default.apsx.cs)
protected override void ClickEvent(EventArgs e)
{
testControl.myProperty = "my value";
}

an when I click on the control, i have a javascript function that
alert the myProperty value.

I know how to set a serverClick event, with IPostBackEventHandler ...

I think I have to deal with ICallbackEventHandler but the alert
javascript function comes too earl and can't know the value of
myProperty, and I don't want the page to be postbacked entirely
because alert function has to come just on the clientclick.
Maybe the good solution is to make something like an autopostback =
true, but I don't know how to make it.

How would you do something like that ?

Thanks for your help.

T.
 
M

Mike Placentra II

(default.apsx.cs)
protected override void ClickEvent(EventArgs e)
{
testControl.myProperty = "my value";
}

an when I click on the control, i have a javascript function that
alert the myProperty value.

You can do that with AJAX. ASP.net has AJAX stuff available here so
you don't have to learn the low level JavaScript stuff like we use
when we aren't using a framework:

http://www.asp.net/ajax/

-Michael Placentra II
 

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,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top