473,396 Members | 1,970 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.

User Control needs to refer to Page

I have a user control which can appear on many pages.
The control needs to know which page it is on so it can render itself
correctly.
What is the best way for the control to find out what page is being
requested?
Code snippet would be great.

Thanks!
--
Joe Fallon

Nov 18 '05 #1
5 1485
You could set a property of the usercontrol on the calling page.

<my:usercontrol runat="server" pageimon="blah.aspx" />

"Joe Fallon" <jf******@nospamtwcny.rr.com> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
I have a user control which can appear on many pages.
The control needs to know which page it is on so it can render itself
correctly.
What is the best way for the control to find out what page is being
requested?
Code snippet would be great.

Thanks!
--
Joe Fallon


Nov 18 '05 #2
Hey man try this, it's been givin me good vibes for weeks.

string pagename = this.Page.Request.CurrentExecutionFilePath;

int pos = pagename.LastIndexOf("/");

pagename = pagename.Substring(pos+1,pagename.Length - pos - 1);

"Raterus" <raterus@localhost> wrote in message
news:uL**************@TK2MSFTNGP09.phx.gbl...
You could set a property of the usercontrol on the calling page.

<my:usercontrol runat="server" pageimon="blah.aspx" />

"Joe Fallon" <jf******@nospamtwcny.rr.com> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
I have a user control which can appear on many pages.
The control needs to know which page it is on so it can render itself
correctly.
What is the best way for the control to find out what page is being
requested?
Code snippet would be great.

Thanks!
--
Joe Fallon



Nov 18 '05 #3
You could either refer to the current context (I think "this" will get you
access to the context in a UC). Or you could pass a reference to the parent
page when the control is created so that you have direct access.

A better way might be to define methods and properties for the usercontrol
and define the state using attribute on the HTML tags. This way the control
does not need to know what page it is one, but rather just needs to know its
state. What happens if you add a new page that requires the usercontrol, do
you always want to update the control, or just pass in parameters?

"Joe Fallon" <jf******@nospamtwcny.rr.com> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
I have a user control which can appear on many pages.
The control needs to know which page it is on so it can render itself
correctly.
What is the best way for the control to find out what page is being
requested?
Code snippet would be great.

Thanks!
--
Joe Fallon


Nov 18 '05 #4
Dan
Or even simpler:

Dim pagename As String =
System.IO.Path.GetFileName(Page.Request.CurrentExe cutionFilePath))
"Felbrigg" <so*****@microsoft.com> wrote in message
news:Ol**************@TK2MSFTNGP11.phx.gbl...
Hey man try this, it's been givin me good vibes for weeks.

string pagename = this.Page.Request.CurrentExecutionFilePath;

int pos = pagename.LastIndexOf("/");

pagename = pagename.Substring(pos+1,pagename.Length - pos - 1);

"Raterus" <raterus@localhost> wrote in message
news:uL**************@TK2MSFTNGP09.phx.gbl...
You could set a property of the usercontrol on the calling page.

<my:usercontrol runat="server" pageimon="blah.aspx" />

"Joe Fallon" <jf******@nospamtwcny.rr.com> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
I have a user control which can appear on many pages.
The control needs to know which page it is on so it can render itself
correctly.
What is the best way for the control to find out what page is being
requested?
Code snippet would be great.

Thanks!
--
Joe Fallon




Nov 18 '05 #5
Lots of good ideas.
Thanks!
--
Joe Fallon
"Dan" <da*@dontspam.com> wrote in message
news:el**************@tk2msftngp13.phx.gbl...
Or even simpler:

Dim pagename As String =
System.IO.Path.GetFileName(Page.Request.CurrentExe cutionFilePath))
"Felbrigg" <so*****@microsoft.com> wrote in message
news:Ol**************@TK2MSFTNGP11.phx.gbl...
Hey man try this, it's been givin me good vibes for weeks.

string pagename = this.Page.Request.CurrentExecutionFilePath;

int pos = pagename.LastIndexOf("/");

pagename = pagename.Substring(pos+1,pagename.Length - pos - 1);

"Raterus" <raterus@localhost> wrote in message
news:uL**************@TK2MSFTNGP09.phx.gbl...
You could set a property of the usercontrol on the calling page.

<my:usercontrol runat="server" pageimon="blah.aspx" />

"Joe Fallon" <jf******@nospamtwcny.rr.com> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
> I have a user control which can appear on many pages.
> The control needs to know which page it is on so it can render itself > correctly.
> What is the best way for the control to find out what page is being
> requested?
> Code snippet would be great.
>
> Thanks!
> --
> Joe Fallon
>
>
>
>
>



Nov 18 '05 #6

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

Similar topics

1
by: | last post by:
I have got two user controls with grids in it. And they have to work as a master detail Grids. And the main thing is i want the detail grid to appear when i click select bound button in the master...
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
4
by: Josh Harris | last post by:
Here is my question: It is common to have many pieces of business logic encapsulated within asp.net user controls. This can be found in high visibility projects such as the iBuySpy portal from...
10
by: George G. | last post by:
Hi there, I am busy writing a new asp.net application and I am reusing some of my existing asp functions and methods in a user control. I need access to session, request and response in some of...
1
by: Martin | last post by:
Hi, I have produced a custom server control that simple outputs a row of 26 buttons, one button for each letter of the english alphabet. now what I would like to do is catch the button click...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
5
by: Annie | last post by:
hello guys, I have a scenario that I am confused about ... I have a number of pages which are using a Master page ... Then I have seperate Footer user control that can reside in master page...
11
by: Web Search Store | last post by:
Hello, I set up a web page with 2 user controls. In classic asp, the first one did all the declarations, and the second one used the values, and could reset it. In ASP.Net so far I can't...
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
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
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
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,...

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.