C# code within HTML

  • Thread starter Thread starter Mike P
  • Start date Start date
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>
 
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.
 
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.
 
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)
 
Back
Top