Reputation: 2399
I have created a web application in which there are two menus which load the same page. I need to check a condition in the page so that I can load different data based on the variable passed to this page. However, I don’t want to use a query string, since that would require using a different URL, which would interfere with SEO.
Is there a way to do this without using query strings or session data? I need to pass different values on clicking different links in the master page.
Upvotes: 1
Views: 13801
Reputation: 23820
I would suggest looking into canonical links.
Using this, you can have two different URL forms, for example bob.aspx and bob.aspx?input=whatever and search engines will only include one of them (e.g. the first) in its index.
Upvotes: 0
Reputation: 4129
Using the reference in the PreviousPage property, you can search for controls on the source page and extract their value. You typically do this with the FindControl method.
use PreviousPage.FindControl("yourcontrolname")
these link may help you
How to: Pass Values Between ASP.NET Web Pages
Upvotes: 2
Reputation: 7370
If your problem with query string is just url changing, you can use post method to send data with using a hidden input. like this:
<form action="products.aspx" method="post">
...
<input type="hidden" id="field1" value="value1"/>
</form>
Or use ajax. You can send http request by means of javascript with ajax. In this case there are no url changing or something. This is an example:
<script type="text/javascript">
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("mainDiv").innerHTML=xmlhttp.responseText; //changing the menu
}
}
params="field1="+document.getElementById("field1").value;
xmlhttp.open("POST","products.aspx",true);
xmlhttp.send(params);
}
</script>
Upvotes: 0
Reputation: 3485
Try window.location.hash: https://developer.mozilla.org/en/DOM/window.location
You could store data after the # in a URL. This is what Twitter does.
Upvotes: 0
Reputation: 65534
Along with the two other answers if the URL is of concern with query string parameters (and you dont want sessions - eg due to in-proc storage), then one alternative to increase your rank with web-crawlers is ASP.NET Routing.
Upvotes: 1
Reputation: 4253
You can use javascript to post data to you page or you can use hidden fields or cookies
Upvotes: 1
Reputation: 15851
you can pass values in many ways. using sessions, cookies, query string, hidden inputs. i personally feel storing query string for menu navigation its not problem, until unless he comes to know exact querystring parameters.
you can try this other methods, Passing Values between webforms
Upvotes: 0