2

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 button.

Does anyone know any way of doing this?

Merry Christmas!

5
  • are you wanting the postback to fire as well? So that the page is altered after submission? Commented Dec 23, 2010 at 10:57
  • yeah, i want the postback to fire...then update the page with relevant JQuery Commented Dec 23, 2010 at 11:10
  • What do you mean by update the page with relevant jQuery? Commented Dec 23, 2010 at 11:12
  • ok, well say the user clicks the Asp.net button >> the c# click event is fired, data is inserted >> Now data is inserted I want the pager control to know which page it was previously on. As the page has posted back,t eh Jquery pager control starts back on page 1. So say I'm making a change to page 2 in the pager control, click the button, update is made, page post backs and displayed page 1 of the pager control where it shoudl display page 2 Commented Dec 23, 2010 at 11:16
  • 1
    i think your better of doing a PRG. post back, redirect to another page with pagenumber in querystring, then set page number based on that QS. Better for SEO. Commented Dec 23, 2010 at 11:20

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

Would an input button enable me to have a postback and update my JQuery?
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.