views:

48

answers:

2

Hello

I'm posting some data from Jquery using Jquery.Post() to an asp.net page. How to get the data in the POST request in asp.net page?

Thank you

NLV

A: 

You can do this by passing querystring.but remember querystring name should be same in the posted page (Which is the parameter).

function ShowProjectInfo(projID) {
            $.post("/PostedPage?projID=" + projID, function(data) {
                alert(data);
            });
        }

Under Code behind page

public void PostedPage(string projID)
{
//code here
}

U can also do it with serialize object.

function ShowProjectInfo(projID) {
var data = $("#frmPrjListEntry").serialize();
            $.post("/PostedPage",data, function(data) {
                alert(data);
            });
        }

frmPrjListEntry is name attribute of form tag. serialize will contain the whole form collection in object.

Under Code page

public void PostedPage(class classname)
{
//code here
}
Amit
I dont want to do it using a query parameter.
NLV
U can also use serialize object.Please find the above example.
Amit
As i've already told in the original post i know to post the data from JQuery. How to read in the asp.net page? What is the code in the place of "//code here" in your post?
NLV
when PostedPage method is called it will take parameter of class object(classname in above example ).This class contains the property of all the fields of ur required code.The main thing that keep in mind is that ur property name and attribute name in form should be same.
Amit
A: 

Okie, i found that you can get the values POSTed from JQuery to asp.net page using

Request.Form.AllKeys

Using the keys, get the value using

string value = Request.Form[key]

Thank you

NLV

NLV