This function permits to submit a page using the GET method.
To submit a page using the get method you need to:
- add this code Form.Method="get"; in the Page_Load method
- Use this code < asp:Button runat="server" ID="btnGenerate" /> as a submit button
- add rel="do-not-submit" attribute to all form elements that you don't want to include in your query string
- change the codebehind logic of your page using Request.QueryString
- disable the page viewstate with EnableViewState="false" (unless it's used for other purposes)
Code
$(document).ready(function(){ enableSubmitFormByGet(); });
function enableSubmitFormByGet(){
if($("form").attr("method") == "get"){
$("form").submit(function() {
$("[name^=" + "ctl00" + "]").each(function(i){
var myName = $(this).attr("name");
var newName = "p" + (i-1);
$(this).attr("name", newName);
});
var qs =$(this).find("input[rel!='do-not-submit'],textarea[rel!='do-not-submit'],select[rel!='do-not-submit'],hidden[rel!='do-not-submit']").not("#__VIEWSTATE,#__EVENTVALIDATION,#__EVENTTARGET,#__EVENTARGUMENT").serialize();
window.document.location.href = "?" + qs;
return false;
});