text for asp:label from session

  • Thread starter Thread starter tshad
  • Start date Start date
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
 
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

Back
Top