Sunday, 15 September 2013

asp.net - Using C# code behind to check if the URL contains a key in order to change the page header depending on what the key is -


I can get one of my pages from different places in the site. Depending on where you are coming from, it may have a URL key, for example, clicking on page 1.aspx on page 1 will take you to page 3.spacks. Clicking on button2 on page2.aspx may also have page 3.aspx but after the page load the final url page 3.aspx? Key = test, while you are clicking on button 1 on page 1.aspx, the URL is only page 3 .aspx.

I want to use the back code to change the header on page 3.aspx. If there is a key in url on page3.aspx, then I have to say that "it is modified due to the title key." If there is no key in it, then I want to keep it as default. The default is currently the text that says "default header".

So far, I've added the code which adds a key to the button href attribute. Page 1's button leads to page 3.aspx and page 2's button page 3.aspx? Key = leads to test, and both pages are loaded. But for some reason my code is not working to change the header. What's in my Page_load:

  if (! IsPostBack) {if (Request.UrlReferrer! = Null & amp; (Request URL.AssolutePath Toolless). This includes (" Key = test "))) {PageHeader =" This is modified due to the title key. "; }}  

It was not working so I tried to remove it from! Put it properly at the beginning of the IsPostBack block and the Page_load method. Instead, I tried to include "(key = ggg") instead, but it was no different. I appreciate any nudge in the right direction

You request the You can use the .txtstring archive:

  if (request .jQuery string ["key"]! = Null) // do something here  

or:

  if (! String.IsNullOrEmpty (request.JQueryString ["key"])  

No comments:

Post a Comment