473,834 Members | 2,001 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access Request.QuerySt ring in Master Page?

Hey Guys,

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

My code is:

public partial class MasterPage : System.Web.UI.M asterPage
{
protected void Page_Load(objec t sender, EventArgs e)
{
SiteMap.SiteMap Resolve += new
SiteMapResolveE ventHandler(thi s.ResolveAdapte r);
}

SiteMapNode ResolveAdapter( object sender, SiteMapResolveE ventArgs
e)
{
SiteMapNode currentNode = SiteMap.Current Node.Clone(true );
string realm =
ContentPlaceHol der1.Page.Reque st.QueryString["realm"];
currentNode.Url += "?realm=" + realm;
return currentNode;
}

Nov 3 '06 #1
3 11458
Nevermind. I used HttpContext.Cur rent.Request.Qu eryString["realm"];

james wrote:
Hey Guys,

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

My code is:

public partial class MasterPage : System.Web.UI.M asterPage
{
protected void Page_Load(objec t sender, EventArgs e)
{
SiteMap.SiteMap Resolve += new
SiteMapResolveE ventHandler(thi s.ResolveAdapte r);
}

SiteMapNode ResolveAdapter( object sender, SiteMapResolveE ventArgs
e)
{
SiteMapNode currentNode = SiteMap.Current Node.Clone(true );
string realm =
ContentPlaceHol der1.Page.Reque st.QueryString["realm"];
currentNode.Url += "?realm=" + realm;
return currentNode;
}
Nov 3 '06 #2
Don't forget to test to see if the Request.QuerySt ring[] 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********@gma il.comwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
Hey Guys,

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

My code is:

public partial class MasterPage : System.Web.UI.M asterPage
{
protected void Page_Load(objec t sender, EventArgs e)
{
SiteMap.SiteMap Resolve += new
SiteMapResolveE ventHandler(thi s.ResolveAdapte r);
}

SiteMapNode ResolveAdapter( object sender, SiteMapResolveE ventArgs
e)
{
SiteMapNode currentNode = SiteMap.Current Node.Clone(true );
string realm =
ContentPlaceHol der1.Page.Reque st.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.QuerySt ring[] 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.Qu eryString != null
&& this.Request.Qu eryString[ "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
7287
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 access the property and control of master page from the customized base page class? Btw, I can access the server control of master page from base page class via
4
6024
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. How can I access the property D from the base page class A? PS: I know how to use reflection to access control of master page C from the base class A.
4
1641
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: public class Home : MyBasePage { ..... } and in it I can simply refer them as base.MyProperty (or just this.MyProperty). This seems no longer possible in the ASP.NET 20 master
2
1083
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 this.Page.thePropertyIwant or this.Parent.thePropertyIwant or
4
4023
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. In my masterpage I have this: private bool m_AlreadyTested; public bool AlreadyTested { get { return m_AlreadyTested; }
4
2974
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 and threads! The problem I am having is, when you first navigate to the site you pass the forum name in a querystring. So foe example: forumid=testforum I do this because the site will host multiple forums and this will allow me to use one DB...
1
8490
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 I fix this and display the date into textbox after selecting the date from Calendar.aspx? This Very Urgent .......................... If any body help me out I have given the following Code ******************************
2
1534
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 but it isn't: MyBody.Attributes.Add("onclick", "TestIt();"); Is there a way to do this from the control?
0
9799
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9646
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10795
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10512
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9332
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7760
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6957
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3083
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.