473,387 Members | 1,673 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,387 software developers and data experts.

UserControl Problem

Can some one please tell me why I keep getting an error saying user has not
been declared when I add the following to a class usercontrol.

User.Identity.Name

If it is the page class then there is no problem!!!

EG:

Inherits System.Web.UI.Page = OK
Inherits System.Web.UI.UserControl = Doesn't work

Can you sue the page class in a usercontrol??? How do I solve this???

Thanks

Nov 19 '05 #1
2 1256
Because user is a property of the Page class. so in the page, when you are
doing

User.Identity.Name

it's really like doing

me.User.Identity.Name

and since me is an instance of Page, it inherits the User property.

A user control inherits from UserControl, instead of Page, and doesn't have
the property. To access the page's user from the user control do:
Page.User.Identity.Name ...as you can see while User isn't a property of
UserControl, Page is...

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Tim::.." <myatix_at_hotmail.com> wrote in message
news:47**********************************@microsof t.com...
Can some one please tell me why I keep getting an error saying user has not been declared when I add the following to a class usercontrol.

User.Identity.Name

If it is the page class then there is no problem!!!

EG:

Inherits System.Web.UI.Page = OK
Inherits System.Web.UI.UserControl = Doesn't work

Can you sue the page class in a usercontrol??? How do I solve this???

Thanks

Nov 19 '05 #2
Thanks!

"Karl Seguin" wrote:
Because user is a property of the Page class. so in the page, when you are
doing

User.Identity.Name

it's really like doing

me.User.Identity.Name

and since me is an instance of Page, it inherits the User property.

A user control inherits from UserControl, instead of Page, and doesn't have
the property. To access the page's user from the user control do:
Page.User.Identity.Name ...as you can see while User isn't a property of
UserControl, Page is...

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Tim::.." <myatix_at_hotmail.com> wrote in message
news:47**********************************@microsof t.com...
Can some one please tell me why I keep getting an error saying user has

not
been declared when I add the following to a class usercontrol.

User.Identity.Name

If it is the page class then there is no problem!!!

EG:

Inherits System.Web.UI.Page = OK
Inherits System.Web.UI.UserControl = Doesn't work

Can you sue the page class in a usercontrol??? How do I solve this???

Thanks


Nov 19 '05 #3

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

Similar topics

2
by: Sascha | last post by:
Hi there, I searched carefully through the web before finally deciding to post this message, because I could not find a solution for my problem. Hopefully someone will have a hint or explanation...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
9
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it...
2
by: sonu | last post by:
Hi all, I have a problem regarding use of a usercontrol in .NET. My usercontrol consists of two listviews which I say as source and destination lisviews which contains the files and folders. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.