473,396 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Access Request.QueryString in Master Page?

Hey Guys,

Do you have any idea how to acces Request.QueryString in a MasterPage?
I need to use it to modify my sitemap.

My code is:

public partial class MasterPage : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
SiteMap.SiteMapResolve += new
SiteMapResolveEventHandler(this.ResolveAdapter);
}

SiteMapNode ResolveAdapter(object sender, SiteMapResolveEventArgs
e)
{
SiteMapNode currentNode = SiteMap.CurrentNode.Clone(true);
string realm =
ContentPlaceHolder1.Page.Request.QueryString["realm"];
currentNode.Url += "?realm=" + realm;
return currentNode;
}

Nov 3 '06 #1
3 11427
Nevermind. I used HttpContext.Current.Request.QueryString["realm"];

james wrote:
Hey Guys,

Do you have any idea how to acces Request.QueryString in a MasterPage?
I need to use it to modify my sitemap.

My code is:

public partial class MasterPage : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
SiteMap.SiteMapResolve += new
SiteMapResolveEventHandler(this.ResolveAdapter);
}

SiteMapNode ResolveAdapter(object sender, SiteMapResolveEventArgs
e)
{
SiteMapNode currentNode = SiteMap.CurrentNode.Clone(true);
string realm =
ContentPlaceHolder1.Page.Request.QueryString["realm"];
currentNode.Url += "?realm=" + realm;
return currentNode;
}
Nov 3 '06 #2
Don't forget to test to see if the Request.QueryString[] array item is not
null before you access it, otherwise you're going to end up with
nullreference errors when the querystring variable isn't present or
misspelled.

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"james" <ja********@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hey Guys,

Do you have any idea how to acces Request.QueryString in a MasterPage?
I need to use it to modify my sitemap.

My code is:

public partial class MasterPage : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
SiteMap.SiteMapResolve += new
SiteMapResolveEventHandler(this.ResolveAdapter);
}

SiteMapNode ResolveAdapter(object sender, SiteMapResolveEventArgs
e)
{
SiteMapNode currentNode = SiteMap.CurrentNode.Clone(true);
string realm =
ContentPlaceHolder1.Page.Request.QueryString["realm"];
currentNode.Url += "?realm=" + realm;
return currentNode;
}

Nov 3 '06 #3
Hi,

Mark Fitzpatrick wrote:
Don't forget to test to see if the Request.QueryString[] array item is not
null before you access it, otherwise you're going to end up with
nullreference errors when the querystring variable isn't present or
misspelled.
Just to be nitpicking, the QueryString array won't be null if the
variable is mispelled, so you should also test if the variable itself is
not null:

if ( this.Request != null
&& this.Request.QueryString != null
&& this.Request.QueryString[ "realm" ] != null )
{
// Do some work
}

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: RedHair | last post by:
I have a ASP.NET 2.0 web page which inherits a customized base page class and have a master page, their relation is as below Customized base page class --> web page --> master page How to...
4
by: RedHair | last post by:
I have a base page class A which inherits System.Web.UI.Page class then a aspx page B inherits class A and have a master page C. There is a property D (a string variable) in the master page C. ...
4
by: Bob | last post by:
In ASP.NET 1.1, I have a base page for all my pages in an application. The base page contains some common properties that every page needs, the code behind file of every page looks like this: ...
2
by: Charlie | last post by:
I have some code in a basePage class public class PageBase : Page {} that I would like to access from a Master Page. On the Master Page I would like to code something like...
4
by: evantay | last post by:
I'm using ASP.NET 2.0 with VS.NET 2005. I'm trying to access properties from my master pages within a page that inherits from that master page (a child page). However the values are always null....
4
by: Javilen | last post by:
Hello, I am developing a forums for asp.net, in doing this I am using code behind to do all validation on users and roles and then using embedded ASP to do the displaying for categories, sections...
1
by: sudip2008 | last post by:
When using the Calendar Popup in a content page of a masterpage the strForName is always set to aspnetForm This breaks this line from working properly window.opener.document.forms...... How can...
2
by: tshad | last post by:
I have the body tag of my page in my master page. <body id="MyBody" runat="server"> In my control that is on the page, I want to set the onload event which I would do if it was in my control...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.