Click to See Complete Forum and Search --> : Changeing URL with a LinkButton and no redirection?
fatbob51
03-17-2008, 01:59 PM
Is there anyway to chnage the browsers URL once you press at a LinkButton, but without redirecting to the URL.....cause once I press a linkButton i want it to update the URL with a variable(such as "mypage.aspx?var=home")..but dont redirect or update the page in anyway...
Thanks in advance!
P.S im quite new to ASP.NEt so if its something complicated then please give me a helping hand and explain it for me as I whould be a five years old kid:o
Nate1
03-23-2008, 04:33 AM
I can't see why you would want to do this, could you explain, if you wanted to make it look like a different page, it would require heavy clientside JavaScript/VBScript? could you explain why you need this and maybe someone could suggest a better alternative?
fatbob51
03-23-2008, 11:15 AM
Ok..well its extreamly complicated to explain but I will do my best...
Ok lets get started I will try to be as clear aspossible..
I have for a long time tried to make a way of just updateing a small part of a website(just an area of the website), but I also want it to be possible for a user to directlly get to the right content of that area.
Lets imagine you have an IFrame, the IFrame works great for what I want to do except two things.
1. you cant redirect a user to the correct Iframe content, lets say you have two links at your site that puts different contents in the Iframe. i want the user to be able to by useing a specefic URL to get the IFrame to load the correct URL.
2. It has scrolls and its height/width aint dynamically changeing deppending on its content.
So thats why I cant use the basic IFrame.
I have now started to use an updatePanel with a label in it instead, and that works great its dynamically changeing its height and width deppending on the labels content..but the thing is as just as the IFrame there is no clever way of just by uisng an URL to get the Label in the updatePanel to load the correct content...or well there is one but its ugly..
As you might have figured out already I have a few LinkButtons outside my updatePanel that triggers the updatePanels update function...but what I also want the LinkButtons to do is to change the broswers URL to for instance:
http://mywebb.com?pageid=News
But without redirecting the user or updateing the entired page again...cause if I just can get that to work I can later make a Queto variable(or what its called) and then just tell my Label in the updatePanel to change Text to the specified "pageid"(which is which Text/Page the Label should load into itself)
Ok to put this simple...I wnat a way to dynamically update an area of a webpage with out updateing the rest of the page, but it should also be able for a user to get back to that page with the correct content in the area...
Hope you guys did understand anything of this...cause I almost didnt myself:p
Thansk in advance!
Nate1
03-23-2008, 03:30 PM
Do you want users to be able to bookmark the state of the page?
Or Ajax Bookmarking.
I have looked at this breifly before but never implemented it, but theres quite a bit of content on the web about it, so Im guessing there must be a solution, like this (http://www.onjava.com/pub/a/onjava/2005/10/26/ajax-handling-bookmarks-and-back-button.html)
What about using the view state if you don't require bookmarking and always start the page at the same state i.e not isPostback,
Also think about how complicated this page is going to get to have this variable content, if in the future its going to get larger, this could become a pain to maintain.
You could also use a Div with ID and type your own AJAX request
function createRequestObject() {
var ro;
var browser = navigator.appName;
if(window.XMLHttpRequest){
ro = new XMLHttpRequest();
}else if(window.ActiveXObject){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}
return ro;
}
var http = createRequestObject();
function handleCatResponse() {
if(http.readyState == 4){
so_clearInnerHTML("divID");
document.getElementbyId("divID").innerHTML = response;
}}
function sndReq(){
httpParent.open('get','Form/HTML/Page.aspx?variables=');
httpParent.onreadystatechange = handleResponse;
httpParent.send(null);
}
onclick="sndReq()"
It would update your content and make the div expand to fit the output, as long as your CSS allows for it.