markzzz
markzzz

Reputation: 47995

Why can't I pass a value to a User Control?

This is my code:

<myOwnCtrls:SocialLabel ID="SocialLabel1" CustomName="<%=CurrentPage.Titolo %>" runat="server" />

but on SocialLabel1, if I write the content of CustomName, it prints <%=CurrentPage.Titolo %>, not the content of CurrentPage.Titolo.

Why? And how can I do it without passing between the code behind?

Upvotes: 0

Views: 48

Answers (1)

nima
nima

Reputation: 6733

You can do that in plain html controls but not in user controls. You have to assign CustomName in code behind:

SocialLabel1.CustomName = CurrentPage.Titolo;

Upvotes: 2

Related Questions