|
Apply style to HTML anchor tag in asp.net code-behind -- psid --
Hi, I want to apply style(e.g. class) to an HTML anchor tag in the code-behind asp.net page. How can this be done? Regards, Siddharth P |
|
-- "Bradley, Peter" --
Just amend the HTML to include it. Is there some reason why you can't do that. (By the way, use of inline styles is not good practice. You should really use external style sheets) Peter -----Original Message----- From: DotNetDevelopment Apply style to HTML anchor tag in asp.net code-behind Hi, I want to apply style(e.g. class) to an HTML anchor tag in the code-behind asp.net page. How can this be done? Regards, Siddharth P |
|
-- Garret117 --
Hey there, To rephrase your question, since I think the guy before me didn't really understand what you're saying: You want the Class field of an HTML tag to be dynamic. Essentially, Correct? If this is what you are asking, then there are two ways of doing this I *think*. The first is rather simple, and how I would do it. I'm sure there is a better way in which you programmatically find the HTML tag, and change it's properties. Much like you would change the properties of a ASP:Button control. Here's my way (in C#, mind you): ................ Note the single quotes around the <%%> public partial class SamplePage_SamplePage : System.Web.UI.Page { public string strClass; protected void Page_Load(object sender, EventArgs e) { strClass = "header"; Page.Databind(); } } I hope this helps. The other method, like I said... I'm not sure about. But if you browse the web for changing HTML element properties you might find something. -Garret117 psid wrote: Hi, I want to apply style(e.g. class) to an HTML anchor tag in the code-behind asp.net page. How can this be done? Regards, Siddharth P |
|
-- Cerebrus --
That is one way that will work, Garrett, but isn't it simpler to just set the Class property of the needed HTML tag in the properties window ? See the following topic in help : "Adding CSS Style Attributes in Design View" |