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? 

0
Niall20
10/8/2007 4:26:17 PM
asp.net.ajax-ui 9760 articles. 0 followers. Follow

4 Replies
2720 Views

Similar Articles

[PageSpeed] 31

How about using a web service call?

Encosia - ASP.NET, AJAX, and more.

Latest article: Using complex types to make calling services less… complex
0
gt1329a
10/8/2007 10:10:51 PM

Thanks for your help.

How could i code that? An example maybe?
 

0
Niall20
10/9/2007 7:12:46 AM
The documentation has pretty good code examples.  See if this helps:  http://www.asp.net/AJAX/Documentation/Live/tutorials/ExposingWebServicesToAJAXTutorial.aspx

Encosia - ASP.NET, AJAX, and more.

Latest article: Using complex types to make calling services less… complex
0
gt1329a
10/9/2007 5:57:03 PM

Niall20:
it will only work in a Page, not a master page.
 

That's because .master file can't work as a httpHandler to server the request. It's blocked. In a simple word, the method in master page can't be accessed from client side directly.

0
Raymond
10/11/2007 8:24:25 AM
Reply:

Similar Artilces:

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

Calling a server side method from javascript without page methods
Hi everyone.  I'm trying to do some like this:  if (confirm("foo") == true) {    MyServerSideFunction(); } 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! You can use ajax to call a webservice from javascript. Check out this article on how to do it: http://www.semenoff.dk/en/Code-Corner/ASP.Net.AJAX/WebService-From-...

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

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

accessing a server side function in a parent page from a server side function found in a page in an iframe
I was wondering if this was possible. I current have a page with a menu where when a menu item is clicked the iframe directly underneath would populate with a specified page based on menu item. From here I would like to access a function based in the parent page when something in the iframe is accessed. Or the very least access the attributes such as the height or width of the main window compared to the iframe from the iframe's page's server function. I am trying to display a separate window for the user through javascript like a modal window which i want to fill up the whole ...

Call server side function from javascript using ajax
Hi, I want to call a server side function from  javascript. Using Ajax.dll I am able to call a simple server side function but server side function containing webservice cannot be called. Does anyone have solution for this?   You should start out by watching this video: http://www.asp.net/learn/ajax-videos/video-79.aspx Hope it helps Thanks for the video.  It worked with ajax.dll. I had missed the Script service namespace in web service....

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

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 a javascript function from server side, using AJAX timer
 Hello,I am developing a ASP.NET ajax application.I am using a timer:<asp:Timer ID="Timer1" runat="server" OnTick="Timer_Tick" Interval="5000" />      The only thing I want to do is to call a javascript function on every tick of the timer: protected void Timer_Tick(object sender, EventArgs e)        {            ClientScript.RegisterClientScriptBlock(this.GetType(), "blink", "<script>blinkit('2');</script>");      &nbs...

call a server side function from javascript function
hello i have apage that is contained in MasterPage (contents) i have a HyperLink and i want to call a serverside function is it possible? i am writing C# nirnironIf i helped you please mark as answered.. in your page_load event, you can reference controls on the masterpage by MasterPage.FindControl("....")  Peter Kellnerhttp://73rdstreet.com and blogging athttp://PeterKellner.netMVP, ASP.NET  Use the "LinkButton" control...  Looks the same as a hyperlink, acts the same, and you can catch events from it. no... ok this is the scenario... i have ...

How to call a javascript function from a server-side function
Hi. I'd like to know if it's possible to call a javascript function from within a server-side function. I know it's possible to associate a javascript function with a control event but I'd like to call it from within an asp.net function.  Thanks, Samir Zattar Hey, There are several ways to do it, all through the Page.ClientScript property.  You can write a script through RegisterClientScriptBlock or RegisterStartupScript, or if you have a script file you can write a reference to that file.Brian"Trust in the Lord and do what is good; dwell in the land and ...

how to call server side function in javascript function
right now I have a question. I have a javascript function which created a textfield. what I want to do is when the user type in the value into the textfield, it will call the function in the server side and search the data in the database. I wonder is it possible to do that? And how to do it, can anyone some me some example..thx    look into ajax autocomplete Liming XuJumptree ASP.NET 2.0 Project Management - With Source Code, Free to Non Profit Org and Effectively Manage Projects/Tasks/Milestones Superwong-You definitely want to use Ajax (as was suggested). Since you're u...

Call a javascript function that returns a value from a master page in .net 2.0
I an trying to get a value from an XSLT file and assign it to a .net hidden input field XSLT: <xsl:attribute name ="onclick">GetId('<xsl:value-of select="@MasterNavLink" />');</xsl:attribute> Javascript on MasterPage var LinkId = null; function GetId(fldVal) {          //fldVal is set when this function is called in the xslt file    try   {  LinkId = fldVal;             document.getElementById('<%= linkIdIF.ClientID%>').value=fldV...

Calling a javascript function in the content page from the master page.
I have an <asp:Menu on a master page and for one of the menuItems navigation url I can use 'javascript:myfunction()' to call a javascript function in the master page. No problem. Now, what I need to do is use that same master page <asp:menu menuItem to call a javascript function in the content page. Does anyone know how I can call a javascript function located in the content page from the master page using an <asp:Menu menuItem navigation url located on the master page? Thanks,   Steve HI On the content page load u need to find the master page ...

Web resources about - Call Server Side method from JavaScript function in Master Page - asp.net.ajax-ui

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: jobs@sometrics.com 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 . blog.mozilla.org/research/2014/… ...

Resources last updated: 12/23/2015 1:52:27 PM