assigning 'class' tag using C# function

  • Thread starter Thread starter divya_rathore_
  • Start date Start date
D

divya_rathore_

Why doesn't the following code work for a [asp.net + C#] project? How
else can I assign the 'class' keyword a value from outside (not
embedded within the asp.net code, say as in: class=class_red)?

//some C# function
String GetCSSClass()
{
return "class_red";
}



//code in asp.net
<head> </head>

<body class = <% GetCSSClass(); %> >
some text using format contained in css class.
</body>
 
Try
<body class = <%= GetCSSClass(); %> >

No, it didn't work for me.. :(

is runat="server" to be specified too? Anything else trivial that I
could be missing?
 
Howdy,

-- Code behind / beside --

protected string GetCSSClass()
{
return "class_red";
}

-- end code --

-- aspx page code --
<head> </head>
<body class="<%=GetCSSClass() %>" >
some text using format contained in css class.
</body>
-- end aspx code

Hope this helps
 
Have something against lesbians do you?

I'm sure there's an obvious rebuttal to this something along the lines of
not having as much against lesbians as I'd like to... ;-)
 
Something *has* been done.
The s.exually-oriented spam has been deleted from the server.

If you reset this newsgroup's message list,
you shouldn't see any s.exually-oriented spam.




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
 

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

Back
Top