1

I'm creating a control and need to pass it the current logon 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 it?

5 Answers 5

2

Why do you need to pass it at all?. The user control can access the User.Identity.Name property directly.

Sign up to request clarification or add additional context in comments.

Comments

1

Inside that control, you will have access to this.Page.User, so that's one way. Another is to use HttpContext.Current.User.

Comments

1

You can do this in the codebehind:

myid.User = User.Identity.Name

Comments

0

Try using:

User="<%= User.Identity.Name %>"

%= is for output

%# is for databinding.

1 Comment

Sorry, I fixed it (I copied and pasted the second thing I tried). I did actaully tried first with "="
0

Try changing the double quotes in the User attribute to single quotes. I've seen that work in the past...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.