text for asp:label from session

T

tshad

How do I set up text (or can I) set up a label to automatically pull in text
from a session variable. Something like:

<asp:label text="<%# session("ClientName") %>" runat="server"/>

This doesn't work, but is there a way to have it do this with out having to
set up code in the Page_Load sub to accomplish this?

Thanks,

Tom
 
K

Karl Seguin

Tom:
Create a custom control:

public class ClientName
Inherits Label

public override sub Render(Writer as HtmlTextWriter)
if not session("ClientName") is nothing then
Text = cstr(Session("ClientName"))
else
Text = "Anonymous"
end if
myBase.Render(writer)
end sub
end class


not tested, but something like that ought to work.

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top