C# code within HTML

M

Mike P

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>
 
E

Eugenio

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.
 
E

Eliyahu Goldin

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


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.
 
B

bruce barker

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)
 

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

Top