开发者

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 ??

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜