Showing posts with label label control. Show all posts
Showing posts with label label control. Show all posts

May 20, 2010

Merging three table fields using DataBinder.Eval to display in a label control (ASP.NET, C#)

<asp:Label ID="lbl_Address" runat="server"  Text=’<%# DataBinder.Eval(Container.DataItem,"Location")+ ", " +DataBinder.Eval(Container.DataItem,"City") +", " +DataBinder.Eval(Container.DataItem,"State")%>’ ></asp:Label>

May 19, 2010

Change CSS of a ASP.NET control at runtime. (C#)

Let's add background color and width  to a Label control at runtime.
(Runtime means on button click event or something like that).

Label1.Attributes.CssStyle.Add("background-color", "#007700");
Label1.Attributes.CssStyle.Add("width", "320px");

How to get current user's name? (ASP.NET, C#)

You can get current logged in user's name in a label control as follows:

Label1.Text = User.Identity.Name.ToString();