Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I am passing values using JavaScript, but I don't want URL to be like this
"Inventory/Asset.aspx?=4"

URL should be like: "Inventory/Asset.aspx"


JavaScript
function next(idx) {
    var aData = oTable.fnGetData(idx);
    window.location = '/Inventory/Asset.aspx?=' + aData["assetID"]
}
Posted

 
Share this answer
 
Comments
Anele Ngqandu 7-Oct-13 11:42am    
Is there anything I can use except cookies?
OriginalGriff 7-Oct-13 11:52am    
Not in javascript: you only get the two options: query string or cookies.
Anele Ngqandu 7-Oct-13 11:56am    
Ok cool
one thing you can do without querystring and cookie.
That is session variable. How?
from javascript you will call ajax functions(ajax/web method and this method should be allow session access) and with in that function/method you store that value to a session variable
Session["key"] = value;
then from other page you read that session value.

This method has its drawbacks though. If you don't remove the variable from session in page #2, the page will behave as if you navigated to the particular assetID whenever that URL is requested, regardless of whether you actually came from page #1 or not. And if you DO remove the variable, the page will NOT behave as expected if the user refreshes the page, or when navigating to it via the back button (unless of course the browser takes the page from cache and does not request it again).

HTTP is stateless. Why not just use the mechanism provided - i.e. the URL - to have the browser say what it's asking for? This is easier and more reliable than having the server "remember" how the user has been navigating, especially since the server may respond but that response isn't certain to reach the browser.

If you really don't like the querystring, you could use a different syntax, e.g. "mysite.com/assets/1010" instead of "mysite.com/assets?id=1010". Doing this is supposedly quite trendy these days, and I think you'll find tons of info on the how and why if you search for "URL rewriting".
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900