开发者

ASP.NET button click fire jQuery

开发者 https://www.devze.com 2023-01-31 18:34 出处:网络
I have a jQuery Pager control, for each page there is a set of textboxes and a submit button. When this submit button is clicked I want it to fire off some jQuery to update the controls on the front e

I have a jQuery Pager control, for each page there is a set of textboxes and a submit button. When this submit button is clicked I want it to fire off some jQuery to update the controls on the front end (i.e. current page, set visibility of controls etc). The button is an asp.net web forms postback butto开发者_JS百科n.

Does anyone know any way of doing this?

Merry Christmas!


Inject js from code-behind after your postback success like:

string script = "$(function(){setPage(\"" + yourpagenumber+ "\");});";
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Pager", script, true);

And in the js you will have a setPage function that does the job of setting page with your jquery pager plugin.

function setPage(pagenumber){
alert(pagenumber);
//do your page setting here
}

Note: you can use Page.ClientScript.RegisterStartupScript if that fits your needs but the idea remains same.


Don't use a submit button, use an input of type button with an onclick event instead.


Use the OnClientClick attribute of the asp:button i.e.

OnClientClick="JQueryFunction();return false;" 

for no postback and

OnClientClick="JQueryFunction();return true;" 

for a postback. I'm assuming that that JQueryFunction() returns true.

0

精彩评论

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