Dynamic Logout Link - with style?

J

Jon Natwick

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
 
F

fd123456

Hi Jon,

hLogout.Attributes["class"] = "myCSSclass";
hLogout.Style.Add("color","#123456");
hLogout.Style.Add("height","32px");

HTH,

Michel
 
J

Jon Natwick

Michel,

You are a genious!

Thank you,
Jon

fd123456 said:
Hi Jon,

hLogout.Attributes["class"] = "myCSSclass";
hLogout.Style.Add("color","#123456");
hLogout.Style.Add("height","32px");

HTH,

Michel

Jon Natwick said:
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
 

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

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top