|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Munging URLs to store datawith no prior ASP or web development experience, but a lot of general programming experience. I'm using Visual Web Developer Beta Express 2005. I'm trying to find a way to store data in the URL of my pages. I know that SessionState does this if you go cookieless, and that's useful but it's not what I want because the real data is stored on the server, and only an ID code is stored in the URL. What I'm doing is implementing a database search that displays results in a manner similar to Google, such that 32 results will be displayed on four pages, with 10 results per page. Of course, there's only one actual "search results" page and the virtual page the user is on is stored in a variable, Session("ResultsPage"). When the user presses the LinkButton to take them to the next page of results, what actually happens is that the variable is incremented by one, the same page is reposted and the Page_Load function fills an HttpPlaceholder Control with the next set of results. Now, this all works excelently... until you take into account the browser's back button. When the user has gone from the Search page to Results Page 1, then Results Page 2, pressing Back should take them back to Results Page 1, but of course it doesn't, since 1 and 2 are really the same page reposted differently due to data in a cookie. Since a browser's history is based on URLs, you clearly want to store the ResultsPage variable in the URL itself, so that Back works properly. If you look at the URLs Google uses when you search, you can see that it does exactly this. So anyway, my question is how you achieve this URL-mangling in ASP.NET. I've read through every description of the HttpSessionState class that I can find, and I can't find any referance to URL- variables in a non-cookieless session. If someone could tell me where in the Framework this functionality could be found, I'd greatly appreuciate it. I just need the procedure calls and class names that are used; I can learn the rest easily myself. Thanks for your time and interest, -- Julian Mensch It sounds like you're looking for the QueryString collection (accessible
through the Request object). The QueryString collection contains all of the name/value pairs contained after the '?' in a given URI. For the URI: http://www.somesite.com/SearchResults.aspx?pageNumber=1 pageNumber=1 is the QueryString. I obviously don't know the specifics of your solution but one way to implement using a querystring is to use a Hyperlink control and set the NavigateUrl property to SearchResults.aspx?pageNumber=1 or SearchResults.aspx?pageNumber=2, etc... To retrieve the value from the QueryString, just use: [C#] int pageNumber = Int32.Parse(Request.QueryString["pageNumber"]); [VB - sorry if this is syntactically incorrect, I usually use C#] Dim pageNumber as integer = Int32.Parse(Request.QueryString.Item("pageNumber")) In either case, when reading the value, you should first make sure that it exists in the collection (It's not null/nothing). HTH ---------------- Dave Fancher http://www.davefancher.com <jmen***@shaw.ca> wrote in message Show quoteHide quote news:1118378538.641998.177210@f14g2000cwb.googlegroups.com... > Hello. I'm a reasonably new ASP.NET programmer > with no prior ASP or web development experience, > but a lot of general programming experience. I'm > using Visual Web Developer Beta Express 2005. > > I'm trying to find a way to store data in the > URL of my pages. I know that SessionState does > this if you go cookieless, and that's useful but > it's not what I want because the real data is > stored on the server, and only an ID code is > stored in the URL. > > What I'm doing is implementing a database search > that displays results in a manner similar to > Google, such that 32 results will be displayed on > four pages, with 10 results per page. Of course, > there's only one actual "search results" page and > the virtual page the user is on is stored in a > variable, Session("ResultsPage"). When the user > presses the LinkButton to take them to the next > page of results, what actually happens is that the > variable is incremented by one, the same page is > reposted and the Page_Load function fills an > HttpPlaceholder Control with the next set of > results. > > Now, this all works excelently... until you take > into account the browser's back button. When the > user has gone from the Search page to Results Page 1, > then Results Page 2, pressing Back should take them > back to Results Page 1, but of course it doesn't, > since 1 and 2 are really the same page reposted > differently due to data in a cookie. > > Since a browser's history is based on URLs, you > clearly want to store the ResultsPage variable in > the URL itself, so that Back works properly. If you > look at the URLs Google uses when you search, you > can see that it does exactly this. > > So anyway, my question is how you achieve this > URL-mangling in ASP.NET. I've read through every > description of the HttpSessionState class that I > can find, and I can't find any referance to URL- > variables in a non-cookieless session. > > If someone could tell me where in the Framework > this functionality could be found, I'd greatly > appreuciate it. I just need the procedure calls > and class names that are used; I can learn the > rest easily myself. > > Thanks for your time and interest, > > -- Julian Mensch >
Other interesting topics
Session State stateserver or Sql Server
Did I do this correctly? - Display resized image from DB. Asynchronous Call <Head>Tag PostBack problem HttpWebRequest.GetResponse on POST returns 405 method not allowed 2.0 App-Code Folder Support for 'Code-Behind' Render and get html from usercontrol OnPreRender ??? What is ? somebody help me answer this? |
|||||||||||||||||||||||