Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > text for asp:label from session

Reply
Thread Tools

text for asp:label from session

 
 
tshad
Guest
Posts: n/a
 
      02-03-2005
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


 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      02-03-2005
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

--
MY ASP.Net tutorials
http://www.openmymind.net/


"tshad" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Session Timeout problems-web.confg session state and IIS session s =?Utf-8?B?Um9iSEs=?= ASP .Net 4 04-11-2007 04:52 PM
Controlling text in a Text Area or Text leo ASP General 1 12-05-2005 01:13 AM
Unable to serialize the session state. Please note that non-serializable objects or MarshalByRef objects are not permitted when session state mode is 'StateServer' or 'SQLServer'. Mike Larkin ASP .Net 1 05-23-2005 12:33 PM
Session State - What does it take to establish one single ASP.NET session per "browser session" Jeff Smythe ASP .Net 3 01-02-2004 04:10 AM
How can I "know" the difference between a session timed out and a session that did session.abort? Jazzis ASP General 2 09-23-2003 07:16 AM



Advertisments