Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

Javascript function with value of server-side event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
timor.super@gmail.com - 20 Dec 2007 06:22 GMT
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.
Mike Placentra II - 23 Dec 2007 03:07 GMT
> (default.apsx.cs)
> protected override void ClickEvent(EventArgs e)
[quoted text clipped - 4 lines]
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.