Board index » Web Programming » Dynamic Logout Link - with style?

Dynamic Logout Link - with style?

Web Programming79
I'm trying to add a dynamically created logout link on my pages.



The link to the logout page will show if the user is logged in.



I put a placeholder on the aspx page and then dynamically create the link,

if the user is logged.



So far, so good. It's working.



Aspx

<asp:PlaceHolder id="phLogout" runat="server"></asp:PlaceHolder>



Cs

System.Web.UI.HtmlControls.HtmlAnchor hLogout = new HtmlAnchor();

hLogout.ID = "hlLogout";

hLogout.HRef = "logout.aspx";

hLogout.InnerText = "Logout";

phLogout.Controls.Add (hLogout);



But the trouble is, how can add a style to the Logout link?



I have tried using this "Style" attribute without success.



hLogout.Style.Add.??? = ???



As well as:



hLogout.Attributes.CssStyle.??? = ???



Any ideas greatly appreciated.



Jon


-
 

Re:Dynamic Logout Link - with style?

Hi Jon,



hLogout.Attributes["class"] = "myCSSclass";

hLogout.Style.Add("color","#123456");

hLogout.Style.Add("height","32px");



HTH,



Michel



"Jon Natwick" <nospamplease@yahoo.com>wrote in message news:<zycOd.4530$w75.2730@twister.rdc-kc.rr.com>...

Quote
I'm trying to add a dynamically created logout link on my pages.



The link to the logout page will show if the user is logged in.



I put a placeholder on the aspx page and then dynamically create the link,

if the user is logged.



So far, so good. It's working.



Aspx

<asp:PlaceHolder id="phLogout" runat="server"></asp:PlaceHolder>



Cs

System.Web.UI.HtmlControls.HtmlAnchor hLogout = new HtmlAnchor();

hLogout.ID = "hlLogout";

hLogout.HRef = "logout.aspx";

hLogout.InnerText = "Logout";

phLogout.Controls.Add (hLogout);



But the trouble is, how can add a style to the Logout link?



I have tried using this "Style" attribute without success.



hLogout.Style.Add.??? = ???



As well as:



hLogout.Attributes.CssStyle.??? = ???



Any ideas greatly appreciated.



Jon

-

Re:Dynamic Logout Link - with style?

Michel,



You are a genious!



Thank you,

Jon



"fd123456" <fd123456@hotmail.com>wrote in message

Quote
Hi Jon,



hLogout.Attributes["class"] = "myCSSclass";

hLogout.Style.Add("color","#123456");

hLogout.Style.Add("height","32px");



HTH,



Michel



"Jon Natwick" <nospamplease@yahoo.com>wrote in message

news:<zycOd.4530$w75.2730@twister.rdc-kc.rr.com>...

>I'm trying to add a dynamically created logout link on my pages.

>

>The link to the logout page will show if the user is logged in.

>

>I put a placeholder on the aspx page and then dynamically create the

>link,

>if the user is logged.

>

>So far, so good. It's working.

>

>Aspx

><asp:PlaceHolder id="phLogout" runat="server"></asp:PlaceHolder>

>

>Cs

>System.Web.UI.HtmlControls.HtmlAnchor hLogout = new HtmlAnchor();

>hLogout.ID = "hlLogout";

>hLogout.HRef = "logout.aspx";

>hLogout.InnerText = "Logout";

>phLogout.Controls.Add (hLogout);

>

>But the trouble is, how can add a style to the Logout link?

>

>I have tried using this "Style" attribute without success.

>

>hLogout.Style.Add.??? = ???

>

>As well as:

>

>hLogout.Attributes.CssStyle.??? = ???

>

>Any ideas greatly appreciated.

>

>Jon





-