How to pass the current user into a web control declaratively
I am creating a control and have to pass it to the current login user as a parameter (declaratively)
I tried this but didn't work (I got "<% = User.Identity.Name%>" as value):
<cc1:MyControl id="myid" runat="server" User="<%= User.Identity.Name %>" />
Is there a way to do this?
+1
juan
source
to share
5 answers
Why would you transfer at all? The user control can directly access the User.Identity.Name property.
+2
HectorMac
source
to share
Inside this control, you will have access to this.Page.User, so one way. Another is the use of HttpContext.Current.User.
+1
Doug McClean
source
to share
You can do it in codebehind:
myid.User = User.Identity.Name
+1
Josh hinman
source
to share
Try using:
User="<%= User.Identity.Name %>"
% = for output
% # for data binding.
0
FlySwat
source
to share
Try changing the double quotes in the User attribute to single quotes. I've seen this work in the past ...
0
Will
source
to share