473,379 Members | 1,201 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

assigning 'class' tag using C# function

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>

Apr 16 '07 #1
9 1316
<% expression %block just executes the expression.

<%= expression %block executes the expression and returns the value.

Try

<body class = <%= GetCSSClass(); %

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"di************@gmail.com" <di**********@gmail.comwrote in message
news:11*********************@n76g2000hsh.googlegro ups.com...
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>

Apr 16 '07 #2
Try
>
<body class = <%= GetCSSClass(); %
aha!

Rest of group members: can't something be done about these unsensored
posts?

Apr 16 '07 #3
"di************@gmail.com" <di**********@gmail.comwrote in message
news:11**********************@y5g2000hsa.googlegro ups.com...
Rest of group members: can't something be done about these unsensored
posts?
It's a public newsgroup...
Apr 16 '07 #4
Rest of group members: can't something be done about these unsensored
posts?
Have something against lesbians do you?
Apr 16 '07 #5
Try
>
<body class = <%= GetCSSClass(); %

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

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

Apr 16 '07 #6
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
--
Milosz
"di************@gmail.com" wrote:
Try

<body class = <%= GetCSSClass(); %

--
Eliyahu Goldin,

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

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

Apr 16 '07 #7
Er, I think you mispelled "public"...

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Mark Rae" wrote:
"di************@gmail.com" <di**********@gmail.comwrote in message
news:11**********************@y5g2000hsa.googlegro ups.com...
Rest of group members: can't something be done about these unsensored
posts?

It's a public newsgroup...
Apr 16 '07 #8
"Aidy" <ai**@noemail.xxxa.comwrote in message
news:PM*********************@bt.com...
>Rest of group members: can't something be done about these unsensored
posts?

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... ;-)
Apr 17 '07 #9
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/
===================================
"di************@gmail.com" <di**********@gmail.comwrote in message
news:11**********************@y5g2000hsa.googlegro ups.com...
Rest of group members: can't something be done about these unsensored posts?

Apr 17 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: gtz669 | last post by:
I have a class which I am using for data stroage. I declare an instance of that class in my main class which is running my java applet. I Iassign it a value in the init () function and it works...
11
by: JohnR | last post by:
I'm trying to find a way to create a variable of a given type at runtime where I won't know the type until it actually executes. For example, dim x as object = "hi" x is declared as an object...
8
by: =?Utf-8?B?VHJlY2l1cw==?= | last post by:
Hello, Newsgroupians: I have a large class with a lot of member variables. I also have a function in the class that I would like to change ALL Of the member variables. I am trying to assign...
3
jullianps
by: jullianps | last post by:
HI everyone, here is my question and I hope it isn't or it hasn't been posted before, probably it has but I spent a few minutes looking through the forums and with the search feature and nothing...
1
by: The Pythonista | last post by:
I've been wondering for a while about whether assigning to __class__ is bad form or not. Specifically, I mean doing so when some other method of implementing the functionality you're after is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.