C# code within HTML

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike P

    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 ***
  • Eugenio

    #2
    Re: C# code within HTML

    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.

    Comment

    • Eliyahu Goldin

      #3
      Re: C# code within HTML

      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]




      "Eugenio" <eugenio@design software.com.br wrote in message
      news:64e04c2b-2e87-4aa7-bb69-1602342de2ae@i7 6g2000hsf.googl egroups.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.


      Comment

      • =?Utf-8?B?YnJ1Y2UgYmFya2Vy?=

        #4
        RE: C# code within HTML

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

        Comment

        Working...