do a postback with javascript to a certain Page Method
What I'm doing now is this:
<d开发者_如何学Civ style="display:none;">
<asp:Button runat='server' OnClick='OnDoClick' ID="b1" />
<asp:HiddenField runat='server' ID="SecretValue" />
</div>
function doPostb(value)
{
$('#SecretValue').val(value);
$('#<%=b1.ClientID%>').click();
}
so basically I need to post to a page method and send some value to it
anybody knows a more straightforward way of doing this ?
Straightforward? Wrap your div in a form tag and do:
$("#your_new_form").submit()
If you want to do it without the page re-loading, you could try jQuery's post function.
If you want to do it without the page re-loading, you could try jQuery's submit function, which would behave the same as the click of a submit button, but might be more semantically appropriate.
You might also want to look at asp.net's doPostBack function.
You can use __doPostBack
method of asp.net Client-library.
function doPostb(value)
{
$('#SecretValue').val(value);
__doPostBack('<%=b1.UniqueD%>','');
}
I can't get that why you mentioned about PageMethods ??
精彩评论