I don’t know if this helps, but I change the name of each input in the form that I want to get fresh values using javascript before submitting the form, since the .net page can no longer match the values from the form with the controls for the page, it reloads them like if there were no postback. I also add a new value to the form, so I know which button submitted the form and uses this logic to decide what to load into all the controls and how to process the form data, of course.
$("#Bset").children().click(function() { //all the btns click function $.each($("form").find("input"), function(e,v) { //could filter this to subset of inputs $(v).attr("name", "_" + $(v).attr("name")); // ctrl1 becomes _cntrl1 }); $("form").append("<input type='hidden' id='b' name='b' value='" + $(this).text() + "' />").submit(); });
then in code <
protected void Page_Init(object sender, EventArgs e) { id = int.Parse(Request.QueryString["id"]); bk = db.dc.getDetailBK(id).Single(); if (Request.Form.Count > 0) doPostBack(); mrl = (from a in db.dc.getMetricQTD(id, null, null, loadSavedGoals) select a).ToList(); }
Then I can do something in dopostback, processing form data, interacting with db, etc., which can change mrl values, load and update data on inputs mrl-bound, regardless of whether they were changed or not the form.
another alternative would be to bind some buttons to using a web service to handle your interaction with db, and then call window.location to refresh the page.
$. Ajax ({
url: "webservice / dbfunction?"
data: {which btn pressed, some form values, etc.}}
success: function () {window.location ("samepage.aspx? id = xxx");}
...
});
this would also avoid server-side response redirection.