473,326 Members | 1,972 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,326 software developers and data experts.

C# code within HTML

I have a HTML menu that I want to add some C# code around which will
include a variable declaration and an if statement. How do I add this
code within my HTML?

*If statement here, if true then show div
<div id="idButton3" class="otherLeftBarLink" onmouseover="javascript:
changeStylesMouseOver('3');" onmouseout="javascript:
changeStylesMouseOut('3');" onclick="location='/AllProjects.aspx'">
<div class="leftBarLinkText">
All Projects
</div>
</div>
*If statement here, if true then show div
<div id="idButton4" class="otherLeftBarLink"
onmouseover="javascript: changeStylesMouseOver('4');"
onmouseout="javascript: changeStylesMouseOut('4');"
onclick="location='/MyProjects.aspx'">
<div class="leftBarLinkText">
My Projects
</div>
</div>

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #1
3 3904
On Jun 17, 11:06*am, Mike P <mike.p...@gmail.comwrote:
I have a HTML menu that I want to add some C# code around which will
include a *variable declaration and an if statement. *How do I add this
code within my HTML?

*If statement here, if true then show div
<div id="idButton3" class="otherLeftBarLink" onmouseover="javascript:
changeStylesMouseOver('3');" onmouseout="javascript:
changeStylesMouseOut('3');" onclick="location='/AllProjects.aspx'">
* * * * <div class="leftBarLinkText">
* * * * * * All Projects
* * * * </div>
* * </div>
*If statement here, if true then show div
* * <div id="idButton4" class="otherLeftBarLink"
onmouseover="javascript: changeStylesMouseOver('4');"
onmouseout="javascript: changeStylesMouseOut('4');"
onclick="location='/MyProjects.aspx'">
* * * * <div class="leftBarLinkText">
* * * * * * My Projects
* * * * </div>
* * </div>

*** Sent via Developersdexhttp://www.developersdex.com***
Mike,

if you put runat="server" in your div , you can manipulate the visible
property in your code-behind C# code.

Jun 27 '08 #2
Just to clarify. Your markup will be in the .aspx file, c# code doesn't need
to produce it, it will just hide/show controls as needed.

And, if it is a menu, you may consider putting it into a user control

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Eugenio" <eu*****@designsoftware.com.brwrote in message
news:64**********************************@i76g2000 hsf.googlegroups.com...
On Jun 17, 11:06 am, Mike P <mike.p...@gmail.comwrote:
I have a HTML menu that I want to add some C# code around which will
include a variable declaration and an if statement. How do I add this
code within my HTML?

*If statement here, if true then show div
<div id="idButton3" class="otherLeftBarLink" onmouseover="javascript:
changeStylesMouseOver('3');" onmouseout="javascript:
changeStylesMouseOut('3');" onclick="location='/AllProjects.aspx'">
<div class="leftBarLinkText">
All Projects
</div>
</div>
*If statement here, if true then show div
<div id="idButton4" class="otherLeftBarLink"
onmouseover="javascript: changeStylesMouseOver('4');"
onmouseout="javascript: changeStylesMouseOut('4');"
onclick="location='/MyProjects.aspx'">
<div class="leftBarLinkText">
My Projects
</div>
</div>

*** Sent via Developersdexhttp://www.developersdex.com***
Mike,

if you put runat="server" in your div , you can manipulate the visible
property in your code-behind C# code.
Jun 27 '08 #3
asp 101

<% if (myCondition) { %>

div id="idButton3" class="otherLeftBarLink" onmouseover="javascript:
changeStylesMouseOver('3');" onmouseout="javascript:
changeStylesMouseOut('3');" onclick="location='/AllProjects.aspx'">
<div class="leftBarLinkText">
All Projects
</div>
</div>

<% } %>

-- bruce (sqlwork.com)
"Mike P" wrote:
I have a HTML menu that I want to add some C# code around which will
include a variable declaration and an if statement. How do I add this
code within my HTML?

*If statement here, if true then show div
<div id="idButton3" class="otherLeftBarLink" onmouseover="javascript:
changeStylesMouseOver('3');" onmouseout="javascript:
changeStylesMouseOut('3');" onclick="location='/AllProjects.aspx'">
<div class="leftBarLinkText">
All Projects
</div>
</div>
*If statement here, if true then show div
<div id="idButton4" class="otherLeftBarLink"
onmouseover="javascript: changeStylesMouseOver('4');"
onmouseout="javascript: changeStylesMouseOut('4');"
onclick="location='/MyProjects.aspx'">
<div class="leftBarLinkText">
My Projects
</div>
</div>

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #4

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

Similar topics

8
by: Frank Ratzlow | last post by:
Hi folks, I have a list of entries where some entries contain the special character (quotes) within in the string. If I try to save this entry everything after the quotes is skipped. The reason...
1
by: Larry R Harrison Jr | last post by:
I have a webpage for showing slideshows. I got the code from http://javascript.internet.com/miscellaneous/image-slideshow.html It's very simple, clean-looking, and small-sized. The only...
1
by: mike c | last post by:
I have a search app that searches local HTML files for a specified term. I then display the pages that contain the term. I would like to highlight the search term within the HTML when it is...
2
by: Michael | last post by:
I'm going through some samples in a book of mine about Data controls. Some of the examples though contain code embedded within the html, something I'd like to avoid. Can someone look at this...
12
by: Joe via DotNetMonster.com | last post by:
Hi, Within the HTML if I try to put an if statement, I get an error: BC30201: Expression expected This is a simplified example: <%# If StoreNumber = "1" Then %> <b>Store1</b>
1
by: nesster13 | last post by:
Dear All, I am a new VB programmer and dont know very much about it so please bare with me. Here is the situation. My professor gave us an e-commerce website to work on but the problem is that...
3
by: Vlad | last post by:
Hi! My task: Take HTML -convert into plain text. Sub-task: 1. Find all urls within HTML (<a href="http://www.abc.com">More about baby bears</a>). 2. And convert them into plain text: More...
2
by: Mike P | last post by:
I have a HTML menu that I want to add some C# code around which will include a variable declaration and an if statement. How do I add this code within my HTML? *If statement here, if true then...
2
by: LindaDhasan | last post by:
Hi, I am a beginner with javascript.Please help me clarify how to display the result of a javascript function within html underline tag.PFA the code. <html> <head> <script...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.