-
Apr 26th, 2012, 09:34 AM
#1
Thread Starter
Frenzied Member
Javascript Postback to ASP.Net
I have the code below which I use for a menu control click event to post data back to the server. However the problem is that on the server when the page loads after being triggered by the code its ASP.Net value is always Page.Postback == false.
I need to execute the code as a postback so I can retain the values selected in the form. I this possible (to fire a postback and not just a post) in Javascript?
Code:
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", this.site.get_url() + this.web.get_serverRelativeUrl() + "/default.aspx");
var hfSourceUrl = document.createElement("input");
hfSourceUrl.setAttribute("type", "hidden");
hfSourceUrl.setAttribute("name", "sourceUrl");
hfSourceUrl.setAttribute("value", location.href);
form.appendChild(hfSourceUrl);
// var hfItemIds = document.createElement("input")
// hfItemIds.setAttribute("type", "hidden");
// hfItemIds.setAttribute("name", "itemIDs");
// hfItemIds.setAttribute("value", ids);
// form.appendChild(hfItemIds);
var hfDownloadAll = document.createElement("input");
hfDownloadAll.setAttribute("type", "hidden");
hfDownloadAll.setAttribute("name", "downloadAll");
hfDownloadAll.setAttribute("value", this.downloadAll.valueOf());
form.appendChild(hfDownloadAll);
document.body.appendChild(form);
form.submit();
-
Apr 26th, 2012, 11:38 AM
#2
Re: Javascript Postback to ASP.Net
I don't use ASP.Net at all, but maybe this is relevant..? If I'm understanding the scenario, you could ignore the jQuery parts of that example, keep the autoSubmit() function that he's made, and use that instead of form.submit() in your code.
Ignore me if I'm way-off though.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|