Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 18th, 2009, 09:31 AM
Authorized User
Points: 166, Level: 3
Points: 166, Level: 3 Points: 166, Level: 3 Points: 166, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2008
Location: , , .
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Post Does anyone know if it is possible to call a C# method from a javascript in ASPX page

Does anyone know if it is possible to call a C# method from a javascript in theASPX page?

e.g:- I have ASPX page (Page1) and a different C# file (File1, which is not the code-behind file of Page1).
  #2 (permalink)  
Old November 18th, 2009, 09:48 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

No you can't do that. Depending on what the Method does in the C# class you could setup an AJAX style request, however, this would require you to create a webpage that linked up to the C# file.

What are you trying to do?
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
  #3 (permalink)  
Old November 18th, 2009, 09:54 AM
Authorized User
Points: 166, Level: 3
Points: 166, Level: 3 Points: 166, Level: 3 Points: 166, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2008
Location: , , .
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Post Does anyone know if it is possible to call a C# method from a javascript in ASPX page

From the javascript in the aspx page 1, the control goes to different C# file1 by the javascript call.

In C# file1, i have a validation(which inturn calls Oracle stored proc) to check if it is success or failure. Right now success and failure message are hardcoded and shown in the Web page based on whether exception is thrown or not.

But going forward , they would have some message coming back from the stored proc which i need to show in the Web page.

Thats what i am trying to see if that is possible.
  #4 (permalink)  
Old November 18th, 2009, 10:03 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Ya you can not directly access a C# class file via JavaScript, however, Microsoft does provide you with some funcationality that makes this somewhat possible. Since you are using .NET 1.x you do not have the luxary of using [WebMethod] to expose Server Side events to your JavaScript but you can setup a Script Callback. This essentially allows you to call a server side method directly from your JavaScript.

Understand though you can't call the C# file directly. The Script Callback must call a Method that exists in your ASPX page and that method can then call your C# file.

Here is how to setup a Script Callback: http://www.codeguru.com/csharp/.net/...icle.php/c9679

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
  #5 (permalink)  
Old November 18th, 2009, 10:09 AM
Authorized User
Points: 166, Level: 3
Points: 166, Level: 3 Points: 166, Level: 3 Points: 166, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2008
Location: , , .
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default Does anyone know if it is possible to call a C# method from a javascript in ASPX page

Thanks. I will go through the article and see how it can be done.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript isnt work well on my aspx page msbsam ASP.NET 2.0 Professional 1 July 11th, 2008 08:00 AM
Javascript with aspx page zaheerabbas.sk ASP.NET 1.0 and 1.1 Professional 2 April 4th, 2007 11:36 PM
aspx page not loading!!!! Method called too soon dba123 C# 0 August 6th, 2006 11:18 PM
How to call a method on a remote object eloyitomio C# 1 July 21st, 2006 10:17 AM
Javascript Works Fine in Aspx page but... vivek_inos Javascript 0 June 14th, 2006 01:57 AM



All times are GMT -4. The time now is 05:32 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.