client side javascript function - called from server side

client side javascript function - called from server side

Post by Derek MacKi » Wed, 23 Jan 2002 00:54:49



Is there anyway to call a client side function from within the click event
of an <asp:Button> Does ASP.NET have any built in utilities to work with
client side code?
 
 
 

client side javascript function - called from server side

Post by Robert Chapma » Wed, 23 Jan 2002 01:20:21


All you can do is add a client side event handler to your asp button.  For
example, the following confirms a delete:

MyButton.Attributes.Add("onclick","window.event.returnValue =
window.confirm('Are you sure?');")

Cheers

--
Robert Chapman, MCSD
Manager Applications Development
prairieFyre Software Inc.
http://www.prairiefyre.com

Quote:> Is there anyway to call a client side function from within the click event
> of an <asp:Button> Does ASP.NET have any built in utilities to work with
> client side code?


 
 
 

client side javascript function - called from server side

Post by Ron Westo » Wed, 23 Jan 2002 01:58:45


Hi Robert

Can you explain why
lkbBack.Attributes.Add("onclick","window.back();");

doesn't work?


> All you can do is add a client side event handler to your asp button.  For
> example, the following confirms a delete:

> MyButton.Attributes.Add("onclick","window.event.returnValue =
> window.confirm('Are you sure?');")

> Cheers

> --
> Robert Chapman, MCSD
> Manager Applications Development
> prairieFyre Software Inc.
> http://www.prairiefyre.com


> > Is there anyway to call a client side function from within the click
event
> > of an <asp:Button> Does ASP.NET have any built in utilities to work with
> > client side code?

 
 
 

client side javascript function - called from server side

Post by Jim Le » Wed, 23 Jan 2002 02:02:20



Quote:> Hi Robert

> Can you explain why
> lkbBack.Attributes.Add("onclick","window.back();");

'Cos window.back is not function?

If you're going to use clientside JS, it might be a good idea to check a
reference.

maybe you want the history object - who knows?

Jim.

 
 
 

client side javascript function - called from server side

Post by Ron Westo » Wed, 23 Jan 2002 02:05:48


window.back is a function



> > Hi Robert

> > Can you explain why
> > lkbBack.Attributes.Add("onclick","window.back();");

> 'Cos window.back is not function?

> If you're going to use clientside JS, it might be a good idea to check a
> reference.

> maybe you want the history object - who knows?

> Jim.

 
 
 

client side javascript function - called from server side

Post by Jim Le » Wed, 23 Jan 2002 02:11:40



TOFU corrected.





> > > Hi Robert

> > > Can you explain why
> > > lkbBack.Attributes.Add("onclick","window.back();");

> > 'Cos window.back is not function?
>window.back is a function

Do you have a reference for this fact?

javascript:alert(window.back)

results in undefined in all browsers I just tested on.

Maybe you created it yourself - if you did you'll need to provide that
code aswell...

Jim.

 
 
 

client side javascript function - called from server side

Post by Wim Hollebrands » Wed, 23 Jan 2002 02:20:23


It does exist. Only in Netscape Navigator 4 though -which you probably
aren't using-, whereas history.back() is supported by *all* browsers.

Wim


> window.back is a function




> > > Hi Robert

> > > Can you explain why
> > > lkbBack.Attributes.Add("onclick","window.back();");

> > 'Cos window.back is not function?

> > If you're going to use clientside JS, it might be a good idea to check a
> > reference.

> > maybe you want the history object - who knows?

> > Jim.

 
 
 

client side javascript function - called from server side

Post by Robert Chapma » Wed, 23 Jan 2002 02:27:04


This can be replaced by a more uniform line of code:

history.go(-1);

Cheers

--
Robert Chapman, MCSD
Manager Applications Development
prairieFyre Software Inc.
http://www.prairiefyre.com

> Hi Robert

> Can you explain why
> lkbBack.Attributes.Add("onclick","window.back();");

> doesn't work?



> > All you can do is add a client side event handler to your asp button.
For
> > example, the following confirms a delete:

> > MyButton.Attributes.Add("onclick","window.event.returnValue =
> > window.confirm('Are you sure?');")

> > Cheers

> > --
> > Robert Chapman, MCSD
> > Manager Applications Development
> > prairieFyre Software Inc.
> > http://www.prairiefyre.com


> > > Is there anyway to call a client side function from within the click
> event
> > > of an <asp:Button> Does ASP.NET have any built in utilities to work
with
> > > client side code?

 
 
 

client side javascript function - called from server side

Post by Ron Westo » Wed, 23 Jan 2002 02:39:47


Thanks Wim

So back to my original question, slightly adjusted... :-)

Can you explain why
lkbBack.Attributes.Add("onclick","history.back();");

doesn't actually go back to the previous page...

The back button appears to 'click' but it doesn't actually show the previous
asp page.

any thoughts?


> It does exist. Only in Netscape Navigator 4 though -which you probably
> aren't using-, whereas history.back() is supported by *all* browsers.

> Wim



> > window.back is a function




> > > > Hi Robert

> > > > Can you explain why
> > > > lkbBack.Attributes.Add("onclick","window.back();");

> > > 'Cos window.back is not function?

> > > If you're going to use clientside JS, it might be a good idea to check
a
> > > reference.

> > > maybe you want the history object - who knows?

> > > Jim.

 
 
 

client side javascript function - called from server side

Post by Jef » Wed, 23 Jan 2002 03:51:53



> Is there anyway to call a client side function from within the click event
> of an <asp:Button> Does ASP.NET have any built in utilities to work with
> client side code?

You can call the Attributes method for your server side control and
pass in your own attributes. In my example below I have passed some
client sitde javascript that responds on my radiobuttons client side
"onClick" event.

rbCreate.Attributes["onClick"] =  "ToggleDisplay('" +
divCreate.ClientID + "', '" + divSearchCriteria.ClientID +"');
ToggleDisplay('" + divProgramsCreated.ClientID + "', '" +
divSearchResults.ClientID +"'); ToggleButtons('" + btnAdd.ClientID +
"', '" + btnSearch.ClientID +"'); ";

Jeff Platt

 
 
 

client side javascript function - called from server side

Post by Robert Chapma » Wed, 23 Jan 2002 04:29:03


Where does it go, if anywhere at all?
Did you try history.go(-1)?
Is the problem in both Netscape and Internet Explorer?

--
Robert Chapman, MCSD
Manager Applications Development
prairieFyre Software Inc.
http://www.prairiefyre.com

> Thanks Wim

> So back to my original question, slightly adjusted... :-)

> Can you explain why
> lkbBack.Attributes.Add("onclick","history.back();");

> doesn't actually go back to the previous page...

> The back button appears to 'click' but it doesn't actually show the
previous
> asp page.

> any thoughts?



> > It does exist. Only in Netscape Navigator 4 though -which you probably
> > aren't using-, whereas history.back() is supported by *all* browsers.

> > Wim



> > > window.back is a function




> > > > > Hi Robert

> > > > > Can you explain why
> > > > > lkbBack.Attributes.Add("onclick","window.back();");

> > > > 'Cos window.back is not function?

> > > > If you're going to use clientside JS, it might be a good idea to
check
> a
> > > > reference.

> > > > maybe you want the history object - who knows?

> > > > Jim.

 
 
 

1. How could I call server-side function from client-side Javascript?

I have a web-form, a button and server-side function that have to run
when the button is clicked. Looks sipmle, but the web-form and the
function are located in one frame and the button is located in
another.

The only way I know to overcome the gap between two different frames
is JavaScript. But I don't know how could I call server-side function
from client-side Javascript.

Thank you for help.

Olga

2. Help: server crashes Urgent!!

3. How do I call a server-side click event after client-side Javascript runs?

4. Seagate ST3660A 545Mb Wanted *URGENT*

5. Calling server-side function from client-side script

6. Boot sector

7. the order of client-side function and server-side function

8. Netmeeting w/ Internet Connection Sharing

9. How do i invoke client side javascript in server side C# method ?

10. Calling client side script from server side event

11. How to call a server side-script when user clicks client-side menuitem ?

12. Calling Server Side Procedures from Client Side Procedures

13. How do call a server side method from a client side script?