Click here to Skip to main content
12,501,486 members (48,421 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


5 bookmarked

Calling a C# server side method with parameters using jQuery

, 9 Sep 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
How to call a C# server side method with parameters using jQuery.

Design a Test.aspx page:

<asp:TextBox ID="Text1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Click" />
<br />
<div id="myDiv"></div>

Design Test.aspx.cs:

public static string ServerSideMethod(string paraml)
    return "Message from Server" + paraml;

Design the client script:

$(document).ready(function () {
    var name = 'stupid';
    $('#<%=Button1.ClientID %>').click(function () {
            type: "POST",
            url: "Default7.aspx/ServerSideMethod",
            data: "{'paraml': " + $("#Text1").val() + "}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            async: true,
            cache: false,
            success: function (msg) {
        return false;

Now execute the script.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Phaneendra Varanasi
Software Developer (Senior)
India India
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralRe: &lt;head runat="server"> &lt;title>Untitled Page&lt;/ti... Pin
keyur soni12-Sep-11 23:43
memberkeyur soni12-Sep-11 23:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160919.1 | Last Updated 9 Sep 2011
Article Copyright 2011 by Phaneendra Varanasi
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid