473,698 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="otherLef tBarLink" onmouseover="ja vascript:
changeStylesMou seOver('3');" onmouseout="jav ascript:
changeStylesMou seOut('3');" onclick="locati on='/AllProjects.asp x'">
<div class="leftBarL inkText">
All Projects
</div>
</div>
*If statement here, if true then show div
<div id="idButton4" class="otherLef tBarLink"
onmouseover="ja vascript: changeStylesMou seOver('4');"
onmouseout="jav ascript: changeStylesMou seOut('4');"
onclick="locati on='/MyProjects.aspx '">
<div class="leftBarL inkText">
My Projects
</div>
</div>

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #1
3 3917
On Jun 17, 11:06*am, Mike P <mike.p...@gmai l.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="otherLef tBarLink" onmouseover="ja vascript:
changeStylesMou seOver('3');" onmouseout="jav ascript:
changeStylesMou seOut('3');" onclick="locati on='/AllProjects.asp x'">
* * * * <div class="leftBarL inkText">
* * * * * * All Projects
* * * * </div>
* * </div>
*If statement here, if true then show div
* * <div id="idButton4" class="otherLef tBarLink"
onmouseover="ja vascript: changeStylesMou seOver('4');"
onmouseout="jav ascript: changeStylesMou seOut('4');"
onclick="locati on='/MyProjects.aspx '">
* * * * <div class="leftBarL inkText">
* * * * * * My Projects
* * * * </div>
* * </div>

*** Sent via Developersdexht tp://www.developersd ex.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*****@design software.com.br wrote in message
news:64******** *************** ***********@i76 g2000hsf.google groups.com...
On Jun 17, 11:06 am, Mike P <mike.p...@gmai l.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="otherLef tBarLink" onmouseover="ja vascript:
changeStylesMou seOver('3');" onmouseout="jav ascript:
changeStylesMou seOut('3');" onclick="locati on='/AllProjects.asp x'">
<div class="leftBarL inkText">
All Projects
</div>
</div>
*If statement here, if true then show div
<div id="idButton4" class="otherLef tBarLink"
onmouseover="ja vascript: changeStylesMou seOver('4');"
onmouseout="jav ascript: changeStylesMou seOut('4');"
onclick="locati on='/MyProjects.aspx '">
<div class="leftBarL inkText">
My Projects
</div>
</div>

*** Sent via Developersdexht tp://www.developersd ex.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="otherLef tBarLink" onmouseover="ja vascript:
changeStylesMou seOver('3');" onmouseout="jav ascript:
changeStylesMou seOut('3');" onclick="locati on='/AllProjects.asp x'">
<div class="leftBarL inkText">
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="otherLef tBarLink" onmouseover="ja vascript:
changeStylesMou seOver('3');" onmouseout="jav ascript:
changeStylesMou seOut('3');" onclick="locati on='/AllProjects.asp x'">
<div class="leftBarL inkText">
All Projects
</div>
</div>
*If statement here, if true then show div
<div id="idButton4" class="otherLef tBarLink"
onmouseover="ja vascript: changeStylesMou seOver('4');"
onmouseout="jav ascript: changeStylesMou seOut('4');"
onclick="locati on='/MyProjects.aspx '">
<div class="leftBarL inkText">
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
22739
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 for this is quite obvious, since the resulting html tag looks like this: <option value="go "again" selected="selected">nochmal &quot;go</option>
1
4379
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 problem--it doesn't start the slideshow when you load it--and it tends to skip to slide #2. (I thus insert a "blank slide"--basically "nothing.jpg"--to make up for this.) The person has to click "start" once the page loads. I'd rather it start...
1
3278
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 viewed. I have the following regular expression code: string searchTerm = "(?<STARTTAG>(<*>.*))(?<MATCHTERM>(" + lastSearchTerm + "))(?<ENDTAG>(.*<*>))";
2
1050
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 and tell me how I could do this from a codebehind page, not the HTML <asp:datalist id="test" runat="server"> <ItemTemplate> <%# Container.DataItem %>
12
1375
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
1652
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 he does all the Html and code within one file. For example normally we create an ASP.net application we will have the choice of doing the design in the design view and the code in the code view. This was not the case, he did both in the same file...
3
1743
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 about baby brears (http:// www.abc.com)
2
1721
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 show div <div id="idButton3" class="otherLeftBarLink" onmouseover="javascript: changeStylesMouseOver('3');" onmouseout="javascript: changeStylesMouseOut('3');" onclick="location='/AllProjects.aspx'"> <div class="leftBarLinkText"> All Projects
2
11651
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 type="text/javascript"> function whichBrs() {
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8895
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2329
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.