Omu
Omu

Reputation: 71288

how to do a postback and get value from my html in that postback

I have a js function

function(id){
// do a postback here and get the id on the server side  
}

I need to send the id to the server, how could I do this?

any way will do, using additional/hidden controls anything

Upvotes: 0

Views: 621

Answers (1)

Tim Schmelter
Tim Schmelter

Reputation: 460288

function(id){
    __doPostBack('', id);
}

On serverside you can access the argument via forms/params collection and the key __EVENTARGUMENT that is an autmatically generated HiddenField:

VB.Net:

Dim ID as String = Request("__EVENTARGUMENT")

or C#:

string ID = Request["__EVENTARGUMENT"];

Understanding the JavaScript __doPostBack Function

Upvotes: 2

Related Questions