Calling a server side method from javascript without page methods

Hi everyone.

 I'm trying to do some like this:

 if (confirm("foo") == true) {



Of course, I can call this function using PageMethods, but since this function in my code behind shold be static, I cannot call others methods inside my class.

Is there any way to call serer side methods without using PageMethods?


Thanks, and sorry for my bad english!

11/27/2007 8:17:32 PM 13973 articles. 1 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 55

You can use ajax to call a webservice from javascript. Check out this article on how to do it:

Hope it helps

11/27/2007 8:27:44 PM


Please remember to click “Mark as Answer” on the post that helps you.
This can be beneficial to other community members reading the thread.

11/28/2007 12:58:37 AM

Hi Everyone :) 

@Klaus Byskov Pedersen

I alread tryed using web services and it works fine, but it's not the case. 



Nice! It works! I noticed that I had to catch this requent inside my OnPageLoad and call the appropriated methods. Now one more question: And if I want do catch this postback inside an WebControl? Actualy I'm catching the postback event inside my control's OnInit event. Is it the right way?


Thanks a lot by the answers.

11/28/2007 10:51:56 AM

Similar Artilces:

Calling Server Side VB.NET code with Javascript just to call a sub method
Hi, Can anyone please give me a clue on how to call my Server side  CalculateResult() method from Javascript code when onchange event is fired??  thanks in Advance Dollarjunkie.Net Web/Software Engineer You will have to use AJAX.  Is there any reason why the CalculateResult logic cannot be handled by Javascript? Best regards...Josh Stodola ← Come check out my blog! The reason is this... I need to have the code go get information based on what is retrieved and then do some calculations based on that and then display the information in one of my controls. I am n...

Call Server Side method from JavaScript function in Master Page
 I have a JavaScript function in a Master Page. The function is below. function Add(q, p) { //call server side method }  I want to be able from within the JavaScript Add function defined above, call a C# server side method and pass the values q and p to it. No value is returned.I have tried PageMethods.CallServerSideMethod(q, p); but it will only work in a Page, not a master page.Is there any way I can do this in a master page?  How about using a web service call?Encosia - ASP.NET, AJAX, and more.Latest article: Using complex types to make calli...

calling Javascript method from server side
I would like to pop-up a message box after doing some checking on the server side. I can do this by using 'this.Page.StartUpScript' but the problem is that if the user clicks on the browser back arrow the message is popped up again. Any ideas? well, think about it. web pages are more like postal mail than a phone connection. while the client is viewing the page, the server has no access to it. so no, not really. what I'd be doing is some client-side validation first, then backing that up with sever-side. is this what you mean? hmmm.... maybe I haven't explained that very clea...

Calling a server side method from javascript
Hi, I have a method in my code behind ie public string GetColor(string imgName){ } This method reads a xml file and returns a value. I want to call this method from javascript with a parameter image name and should return a value to me which I will be displaying on screen. Is anyone know how to achieve this using ajax. This is an urgent!! Thanks     Hi check this sample working code <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Trigger.aspx.cs" Inherits="Trigger" %> <!DOCTYPE html PUBLIC "-//W3C/...

Calling Server Side Method from JavaScript.
How can i call server side method from Javascript. Ajax Pro.dll 1.  by using AjaxPro.dll we can call serverside Method. In that Server Side Method we marked as Ajax.Method. 2.  Server side method No need for Static Method. I want Ajax How can i call server side method. Asp.Net Ajax 1. Static Method 2. Marked as web service. using ajax not possible for non-static methods or not. Why webmethod attribute required for server method. Please give me some sample code or url. To Implement best way of calling server side method.       &...

Call server-side method from Javascript?
Is it possible to call a server-side method from within the javascript? For examle, example.aspx: <script type="text/javascript">    function TestScript()    { TestServer(); } </script> example.aspx.cs protected void  TestServer() {} Thanks for any information. I am also seeking for the solution of the same problem,Prashant No you can't! Workaround of this will be to pass some argument to page and after trapping that argument at server side..and then calling desired function. Here is the code snippet: Understanding that you h...

Calling a Page Method Instead of a Web service method with javascript?
Hi All,I am just wondering if it is possible to call a page method or a static method (non webservice) with javascript and have it return the results to the calling javascript funciton just like how it is done with a webservice call? Personally I prefer not to be producing asmx's for things that may only be used on a single page. If so ... how might I accomplish this?If Not..... Why not?heheThanks Hi miskiwYes you can do that, you can find details here at the bottom of the page titled "To call a static page method".It is wo...

call server side method thru javascript
can anyone tell me how can i call server side methods of my class/webservice thru javascript Several ways.. Here is one:  javascript:function foofoo() { var myButton = document.getElementById('<%= myButton.ClientID %>');    if (myButton!= null)    {;    }}and in code behind: call your function from the myButton.Click sub..  Protected Sub myButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles myButton.Click      ...

Call Server-Side Method in Master Page from client
Hello! I'm trying to call a server-side method from javascript. The server-side  method is in the code-behind of my Master Page and the Javascript function is called in a page that uses the Master Page. Currently I'm getting an error "PageMethods is not defined" when I try to call the server-side method, however, if the method is in the code-behind of a page that uses the Master Page it works. Explaining...Demos.aspx uses a MasterPage, the MasterPage loads a Javascript file and has a WebMethod in the code-behind, Demos.aspx calls a function in the loaded Java...

How to call non static server side method from javascript?
Hi,I want to bind a datagrid using non-static server side code, on a onclick JavaScript function. Thanks in advance     Hi, I have a Datagrid, which have two child grids enclosed in a div. I am planning not to load all the grids with data, rather trying to load childs on div expand event.How can I call the server side method to populate the grid onclick event of an html control. Thanks in advance Hi silverlightps3, To call a Code-Behind event handler using a JavaScript function you can have a look at this thread: how to call c# function from javascri...

JavaScript syntax to call a server side C# method
I have a javascript function to programatically hide and show a collapsiblepanelextender. This is working great.I now need to evaluate if the javascript function is to be executed. To do this I need to call a server side method named CountPhotographDetails() that returns an int.How do I write the JavaScript syntax to call this server side C# method?Below is my javascript code. The first line is the syntax issue:if (CountPhotographDetails() < 1) {  var cpex_photograph = $find("CollapsiblePanelExtenderPhotographDetails_BehaviorID");  if (cpex_photograph.get_Collapse...

Call codebehind method from aspx page OR call javascript function of usercontrol control from page
Hi, I have a page which contains a user control.  When a user clicks on a submit button, I'd like to detect when elements in the user control have changed and popup a message box if changes have been detected to confirm if the user wants to save the changes. Obviously the message box is executed using javascript.  But I'd really like to be able to call a method in the code behind of the page which queries the user control if it has changed.  Is there a way of calling the code behind method from within a javascript function? Otherwise, if I make all the functions execut...

Calling Non-Static server methods from client side javascript
I have some UI controls in an UpdatePanel.  I need to be able to call a NON STATIC method in my server side code behind file that will change some data in the UI controls within the UpdatePanel then update said panel.  I cannot use "PageMethods" since this only works with static methods.  How do you do this?  A web service?  and if so how do you call methods in your page's code behind file using a web service when the service itself is a different class.  Would you make the service fire an event that the current page would handle?  That doesn&...

How to call server side function by javascript using Ajax.Net
Sir, I want to call the server side function by javascript function. Is it possible using Ajax.Net (System.Web.Extensions.dll or AjaxControlToolkit.dll)? If yes then please give me the code or URL. I found some article using Ajax.dll but I want to use System.Web.Extensions.dll or AjaxControlToolkit.dll. Please help me. Thanks in advance Paresh        Hi, Ajax.NET and ASP.NET AJAX, what you want, are completely different implementations so please be sure to use the correct terminology in the future as there are already 100+ AJAX frameworks aroun...

Web resources about - Calling a server side method from javascript without page methods -

JavaScript Kit- Your comprehensive JavaScript, DHTML, CSS, and Ajax stop
Your comprehensive JavaScript, DHTML, CSS, and Ajax stop

Let's Code: Test-Driven Javascript by James Shore — Kickstarter
James Shore is raising funds for Let's Code: Test-Driven Javascript on Kickstarter! A screencast series focusing on rigorous, professional Javascript ...

Eloquent JavaScript: A Modern Introduction to Programming
... and pragmatics. I loved the tutorial-style game-like program development. This book rekindled my earliest joys of programming. Plus, JavaScript! ...

Lightbox (JavaScript) - Wikipedia, the free encyclopedia
On a Lightbox-enabled page, a user can click an image to have it magnified in a Lightbox window, which resizes itself according to the size of ...

Open Directory - Computers: Programming: Languages: JavaScript: Tools: Obfuscators
about dmoz - help Top : Computers : Programming : Languages : JavaScript : Tools : Obfuscators Tools for obfuscation/compression JavaScript code. ...

Facebook File-Transfer App Pipe Relaunches, Now Works Via JavaScript, WebRTC
... allowed Facebook users to send and receive files up to 1 gigabit in size. A new version of Pipe debuted Monday, and the app now works via JavaScript ...

Under the Hood: The JavaScript SDK - The use of polyfills - Facebook
Facebook Engineering hat eine Notiz mit dem Titel Under the Hood: The JavaScript SDK - The use of polyfills geschrieben. Du kannst den vollständigen ...

JavaScript SDK - Facebook-Entwickler
Overview The JavaScript SDK provides a rich set of client-side functionality for accessing Facebook...

Senior Front-End Developer (Javascript and AJAX)
Company: Sometrics Category: Software Development Location: Los Angeles, CA How to Apply: Description: We are looking for ...

Badass JavaScript (@badass_js) on Twitter
WebGLWorker is an open source library that allows using WebGL from Web Workers. Great work as always from @kripken .… ...

Resources last updated: 12/6/2015 6:18:36 PM