How do you create a query string with JavaScript and access the values in Code Behind
-
Hi I would like to know how to construct a query string with JavaScript and to then be able to access the passed values in the code behind. Can someone show me how? Thanks
AndyASPVB wrote:
how to construct a query string with JavaScript
What does it mean? Yes, if are able to create the string, you can save the string in server side hidden field and then can access it from codebehind.
Cheers ! Abhijit Codeproject MVP
-
Hi I would like to know how to construct a query string with JavaScript and to then be able to access the passed values in the code behind. Can someone show me how? Thanks
Hi, You can try this: function QueryString(qs) { s = location.href; s = s.replace("?","?&").split("&"); re = ""; for(i=1;i<s.length;i++) { if(s[i].indexOf(qs+"=")==0) { re = s[i].replace(qs+"=",""); } } return re; } then you can do sth to access the pass to anywhere.
-
Hi I would like to know how to construct a query string with JavaScript and to then be able to access the passed values in the code behind. Can someone show me how? Thanks
A similar thing is done in XMLHttpRequest...GET method to be more specific! create a URL with query stings and call it. Access the querystrings using
Request.QueryString["QSName"]
-
A similar thing is done in XMLHttpRequest...GET method to be more specific! create a URL with query stings and call it. Access the querystrings using
Request.QueryString["QSName"]
Hi I am almost there, but I am getting a problem with multiple postbacks. You see, I need to have my javascript function on an asp:panel scrollbar, and in my js, I wrote this: function scrollPos(position) { window.location.href="default.aspx?scrollPos="+position.scrollTop; } When I move the scrollbar, the page constantly posts back in an uncontrollable manner, flickering away! How do I stop this, so it is smooth and the page is workable?
-
A similar thing is done in XMLHttpRequest...GET method to be more specific! create a URL with query stings and call it. Access the querystrings using
Request.QueryString["QSName"]
-
Hi I am almost there, but I am getting a problem with multiple postbacks. You see, I need to have my javascript function on an asp:panel scrollbar, and in my js, I wrote this: function scrollPos(position) { window.location.href="default.aspx?scrollPos="+position.scrollTop; } When I move the scrollbar, the page constantly posts back in an uncontrollable manner, flickering away! How do I stop this, so it is smooth and the page is workable?
From this reply of yours it looks like you want to maintain scroll position on postbacks. Is that so? If so, there are other ways simpler ones to do it. Why you thought of querystring? Have a look at these: Maintain GridView Scroll Position and Header Inside Update Panel[^] Maintain Scroll Position in Panel, Div[^] P.S.: At any time you can update your question or conversation if needed.
-
From this reply of yours it looks like you want to maintain scroll position on postbacks. Is that so? If so, there are other ways simpler ones to do it. Why you thought of querystring? Have a look at these: Maintain GridView Scroll Position and Header Inside Update Panel[^] Maintain Scroll Position in Panel, Div[^] P.S.: At any time you can update your question or conversation if needed.
Hi I have already looked at the maintain scroll bar position and this only works on the browser scroll bar and not on asp:panel. Plus I actually have a number of panels which could all be in different positions, which is why I need to use JS and query strings