Call a Sever side method from Client Side Javascript.

Hi Friends,

 Can you tell me how can i call a Server Side method of mine from Javascript?


function StoreURL()




Is this the correct method?

Any suggestions would be appreicated.



11/26/2007 5:51:03 PM 24353 articles. 1 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 37


document.getElementById allow you to access elements from html page  DOM in client side.

to call server method from client you have to use  AJAX see this example and read this tutorial.

hope it helps


code less, think more!
11/26/2007 7:27:59 PM

Or do a PostBack:

// Client-side code
<script type=text/javascript>
function StoreURL()
 <%= GetPostBackEventReference(this, "yourMethod") %>;
// -->

// Server-side code
private void Page_Load(object sender, System.EventArgs e)
 if ( this.IsPostBack )
  string eventArgument = (this.Request["__EVENTARGUMENT"] == null) ? string.Empty : this.Request["__EVENTARGUMENT"];

  if ( eventArgument == "yourMethod" )


11/26/2007 7:47:45 PM

Similar Artilces:

Call Server Side methods from Client Side
Hi, How to call Server Side methods from ClientSide with results back. Earlier we were using Anthem approach but now want to use some thing with AJAX. Thanks in Advance.  RegardsSreenivas. you can use the page methods of the ClientScript  control ,please read  : Regards,Anas Ghanem.Note:Please Don't hesitate to click "Report Abuse" link if you noticed something wrong on the forums (like duplicate ,Off-topic,offensive,or any post that violates the website "TERMS OF USE...

Call server side method from client side...
I'm using Jquery to call a modal popup dialog and depend on what user select i nead to call a method to populate my generic list can that be don or is no posible way to do that...     Sorry for my bad english...Florim Maxhuni  If you need to call the server from the clientside, you need to look into Ajax Eric | Twitter epascarello | LinkedIn...

How to call server side function from client side JavaScript?
I want to call a server-side function, like a button's click event or just another private or public function , from a client-side JavaScript function. How do I do that? thanX AnzIf this post was useful to you, please mark it as answer.ClientSideAsp.Net | Blog Maybe alittle more that you need, but....... 1) Put a button on the page. Lets say its id is Button1. Make sure that its has causesValidation=false 2) Write the code for the button. 3) Write the following in the PAge_Load event Button1.Attributes.Add("onClick", "myJSFunction(); return false") 4) Copy this javascript...

how to call server side function from client side javascript?
Hi all, I have a image button in the update panel. I would like to call a method from server side (not from webservice) to get the variable when Onclick on the image button is invoked. Is there any way that I can able to access this function from the client script? In using the UpdatePanel, in essence, you're already doing this because there will not be a full postback.  You can make an asynchronous call to your Click method of your ImageButton.  So, what do you want to do with this "variable"?Christopher Reed"The oxen are slow, but the earth is patient."...

Calling server-side methods from client-side event
Hello,i'm novice in client-side script and i have a simple question: is it possibile to call a server-side method (ex. c# managed code) from a java script client-side function linked to an event?Thanks all  Luca GuccioneGenova, Italy Yes you can. It's very easy using web methods from code behind, jquery and the script manager. See this very good blog post explaining the steps: mySoZa lucaguccione: Hello, i'm novice in client-side script and i have a simple quest...

Call server side function from client side javascript
I have a javascript where I either need to call an onclick even of a server link button or I need to be able to call a server side function.   The only thing is I cant use AJAX.  Is there any way I can do this or am I spinning my wheels. Thanks!-------------Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue. I have a similar problem.  In my case, I would like to set a server-side session object from JavaScript.  Any suggestions?  Thanks.  Dan Sure, y...

How to call server side(C#) function from Client side(Javascript) function?
Hi i have used below functions,  function HandleOnClose() {// this function will be called after clicking browsers close button in Internet explorer if (event.clientY < 0) { event.returnValue = 'Are you sure you want to leave the page?'; } // if he clicks ok then i need to call one server side function in this instance.. else not. } <body onbeforeunload="HandleOnClose()" leftmargin="0" rightmargin="0">other controls in page..</div>  How to achieve this? Thanks MS AJAX Extensions would be the option of choice here. Combined with webservices you can...

Can you call a c# on the server side from javascript functions on client side
Hello guys This is something intresting I have come across during development. I have a javascript written in a .JS file , to my knowledge the .js files are executed on the server side. But security concerns with java script that these .js files can be access by connecting to port 80 of the server . So an ultimate alternative reminas to call c# code from a java script function. Can anyone Help me on this matter Regards Nihar Hi Nihar, Usually .js files executed on client side. Please explain your configuration.Leon LangleybenMCSD, ASP.NET MVPBlog...

How to write data to a file in client side using javascript or someother client side scripting language.
Hi, I would like to know how to write a data to a client side file using javascript or someother client side scripting language. The file type expected is ini file. txt file would also be appreciable. Thanks in advance.   If the site is a trusted and you are running IE then you could try The Old Sewing FactoryThat twitter nonsense. You can write to the server, but not to the client's machine.  Being able to do so would be a huge security breach.When you ask a question, remember to click "mark as answered"...

Is it possible to call client side function from server side code without initial client request?
Atlas is great. I'm using timer to periodically check database changes on server to populate client side controls with new data. Is it possible to do it without a lot of client requests to server which takes a huge useless network traffic? Server should call client side function on all connected clients when, for example, 'database updated' event occurs on server. Thanks. Hi~ Just for your interest, I think you could have a look at Comet, many web IM like Gmail's embeded Gtalk and are built on this architecture你好! Just FYI o_O...

Calling a sever side code behind sub routine from client side java script
Hi is it possible to call a server side sub routine from client side javascript what I what to do is call a form based email routine from the client, I am hoping that by doing it this way I can disable the button used to call the routine imeadiatly so it's only possible to click it 1 time to prevent the same email being send multiple times, and in addtion start a client routine to indicate the email is underway with some graphic of some sort so the use knows that something is happening, all this is because if the attacment is quite large it takes a little while for the procees to...

How to call server side function on client side
Hi,   How to call server side function on client side? here i want to call change() function on textbox onchange event.   <script language="javascript">    function serverfunction()    {    }    </script><input id="Text1" onchange="javascript:serverfunction();"  type="text" /> code behind:  public void change()    {        Response.Write("hello");    } <script type=&quo...

Calling server side scripts from client side
Hello, Can Anyone help out from the following : It is regarding calling server side scripts from client side events. I am able to instantiate a jaguar component in the server side script written in the body of the HTML page as follows : <% var mycomp = java.CreateComponent ("pkg_dispatch/n_jaguar", "iiop://jaguar:9000", "Jagadmin", "" ); if (mycomp == null) { document.writeln("ERROR: failed to instantiate !"); return; } %> I want to use the instance of the jaguar component else wher...

server side variables in client side javascript
I want to use an variable in client side javascript.In regular asp I used hidden fields.what is the best way to do this in ASP.NET ?thx,Intersee my blog at and check the future of open mobile widget solutions at By and large, I personally still use Hidden fields to store information, that either my Javascript function or my code-behind use.  I barely use the RegisterScriptBlock method(s) and that is only for situations where I want to be really dynamic with the client side functionality.  95% of the time, I can still use a...

Web resources about - Call a Sever side method from Client Side Javascript. -

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! ...

JavaScript - Wikipedia, the free encyclopedia
programming styles. JavaScript was formalized in the ECMAScript language standard and is primarily used in the form of client-side JavaScript ...

Open Directory - Computers: Programming: Languages: JavaScript: Tools: Obfuscators
... editor - report abuse/spam - help the entire directory only in Tools/Obfuscators Description Top : Computers : Programming : Languages : JavaScript ...

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 ...

The Facebook SDK for JavaScript provides a rich set of client-side functionality for adding Social Plugins, making API calls and implementing ...

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: 1/15/2016 5:16:04 PM