简体   繁体   中英

HTML,Asp.net and Javascript Menu not working

I have a menu.js file in solution, and a masterpage.aspx :

One of the codeblock of masterpage as follows

<body>
    <table id="table2" blah blah>
        <tr>
            <td valign="top">
                <table border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td><img id="img" blah blah />
                        <td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td style="height: 14px">
                 <%SelectJSMenu%>
            </td>
       </tr>
   </table>
</body>

In code behind masterpage.aspx.vb

  Public Sub SelectJSMenu()
  {
      Select Case System.Configration.ConfigurationManager.AppSettinges("stage")
          Case 1
             Response.Output.Write("script") 'loading menu.js file via script
          Case 2
             Response.Output.Write("scirpt") 'loading another menu2.js file via this script

  }

What I have to do is to check the user permission and write this menu if user is not who he claims to be, then load the second.

I'm not expert in js and asp but reviewing your post, I think the problem is that you don't close your <td> tag in the second enclosed table:

_edit: there's some exception in html which allow tag omission, and < td> tag is part of them. But complex parser could have a more strict validation stage that could complain about it.

try replace:

                <tr>
                    <td><img id="img" blah blah />
                    <td>
                </tr>

by:

                <tr>
                    <td>
                        <img id="img" blah blah />
                    </td>
                </tr>

Apart from an issue with the closing of the tag as mentioned in @jp's answer, the following needs to be corrected.

Instead of

 Case 1
             Response.Output.Write("script") 'loading menu.js file via script
 Case 2
             Response.Output.Write("scirpt") 'loading another menu2.js file

do-

Case 1
             Response.Output.Write("<script src=\"menu.js\"></script>") //loading menu.js file via script
 Case 2
             Response.Output.Write("<script src=\"menu2.js\"></script>") //loading another menu2.js file via this script

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM