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

C# 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
2 1705
There are several approaches but for you perhaps the easiest to understand
and implement could be the following:

<div id="idButton3" runat="server"
style="visibility:hidden">
....
</div>
<div id="idButton4" runat="server"
style="visibility:hidden">
....
</div>

You are telling the compiled each div is now an HTML Control. By default
each control is not visible at runtime. In code you are going to determine
which control should be visible and displayed. The source for each div will
remain visible in the HTML but only one HTML control will be displayed and
active on the UI at runtime...

// Your C# code...
#region Task: Determine display of idButtons...
HtmlGenericControl button3 =
FindControl("idButton3") as HtmlGenericControl;
HtmlGenericControl button4 =
FindControl("idButton4") as HtmlGenericControl;

// determine which to make visible
if(some condition is true)
{
button3.Visible = true;
}
else
{
button4.Visible = true;
}
#endregion

<%= Clinton Gallagher

"Mike P" <mi*******@gmail.comwrote in message
news:uf**************@TK2MSFTNGP06.phx.gbl...
>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 #2
You should ask this question the ASP.NET group.

--
Pete
=========================================
I use Enterprise Core Objects (Domain driven design)
http://www.capableobjects.com/
=========================================
Jun 27 '08 #3

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

Similar topics

5
by: Donald Firesmith | last post by:
Are html tags allowed within meta tags? Specifically, if I have html tags within a <definition> tag within XML, can I use the definition as the content within the <meta content="description> tag? ...
6
by: Mike Daniel | last post by:
I am attempting to use document.write(pageVar) that displays a new html page within a pop-up window and the popup is failing. Also note that pageVar is a complete HTML page containing other java...
7
by: Go USA! Go Israel! | last post by:
I was wondering if the following was possible: Instead of using a frameset which references other individual HTML files, have the <SPAN> tag reference another HTML file, which is placed within...
4
by: Oscar | last post by:
I am quite new to the ASP scene. I want to display the results of a recordset into a third party grid control called VSFlexgrid. I've prepared one asp page which queries an Access database and...
4
by: Ralf Koms | last post by:
Hi, I would like to reference some other HTML files within an "main" HTML file (within the "header"), Something like this: <link rel="part1" href="file1.htm"> <link rel="part2"...
7
by: David Hayes | last post by:
I tried finding an answer on http://www.quirksmode.org/ without success. I am attempting a complicated Frames structure. I have made it work in IE, but not Netscape. I begin with three...
4
by: Stu | last post by:
Hi, I am writing a content management system that has to have W3C compliant output. The pages are template driven and there are special strings within the template to be used as placeholders for...
3
by: Water Cooler v2 | last post by:
Questions: 1. Can there be more than a single script block in a given HEAD tag? 2. Can there be more than a single script block in a given BODY tag? To test, I tried the following code. None...
1
by: daniellee2006 | last post by:
I am creating a basic website to store people profiles and within this website i have a page that creates a table dependent on the number of records in mysql written in PHP within these tables...
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
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,...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.