开发者

Doing a POST from Jquery to an asp.net page and getting the values in the page

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


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
}


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜