Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Introduction:

Here I will explain how to send or pass multiple parameters using JQuery or JSON in asp.net.

Description:

In previous posts I explained articles relating JSON in that I explained how to call page methods using JSON or JQuery in asp.net or Auto complete textbox with JQuery/JSON in asp.net. Now I will explain how to pass or send multiple parameters using JQuery or JSON in asp.net.

If we want to send or pass multiple parameters using JSON or JQuery in asp.net we need to declare it like as shown below


$.ajax({
type: "POST",
contentType: "application/json;charset=utf-8",
url: "SaveAudiVideo.aspx/SaveData",
data: JSON.stringify({title: 'value1' ,songPath: 'value2' }),
dataType: "json",
success: function(data) {
$('lbltxt').text(data.d);
},
error: function(result) {
alert("error");
}
});
Here JSON.stringify is used to encode the parameters in JSON format and our webmethod will be like as shown below

C# Code

[WebMethod]
public static string SaveData(string title,string songPath)
{
string str = string.Empty;
return str;
}
VB.NET Code

<WebMethod()> _
Public Shared Function SaveData(ByVal title As String, ByVal songPath As String) As String
Dim str As String = String.Empty
Return str
End Function

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

1 comments :

karthikeyan s said...

hi suresh i have tried the same but it is not working for me...is there anyother thing i want to include in my project like asp.net ajax or JSON(newtonsoft json) ? my mail id is: karthikeyanmca42@gmail.com
i am trying this asp.net with jquery ajax for a long time. i understood the concepts but its not working for me .
thanks and regards
karthikeyan s (karthikeyanmca42@gmail.com)

Give your Valuable Comments

Other Related Posts

© 2010-2012 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.