patriot16
patriot16

Reputation: 29

How to properly hide runat="server" div?

I am trying to hide div with ID form123 which is runat="server" and everything I tried it doesn't work. I tried these two options:

form123.Style.Add("display", "none");
form123.Visible = false;

None of this is working

Here is my code:

<div id="form123" runat="server">
    <a id="text">Some text:</a>
    <div style="height:10px;"></div>
    <form id="frm" runat="server" >
    <asp:TextBox ID="txt123" TextMode="Password" runat="server" />
    <asp:Button ID="btnSubmit" Text="Prijava" runat="server" />
    </form> 
</div>
    <% if (txt123.Text == "text") { 
        form123.Style.Add("display", "none");
        form123.Visible = false; 
        info = new DirectoryInfo("\\\Ostalo");
        files = info.GetFiles().OrderByDescending(p => p.CreationTime).ToArray();
        foreach (FileInfo dat in files){
            var test=dat;
            if(test.ToString() != "Thumbs.db"){ %>
        <li class="seznam_razmak"><a  href="//Ostalo/<%=dat%>" class="link1" target="_blank">&nbsp&nbsp<%=dat%></a></li>

    <% }}}%>
    </div>

Upvotes: 1

Views: 89

Answers (1)

Alex Leo
Alex Leo

Reputation: 2851

Try putting your razor code before the div element. I have recently encountered the same issue with some legacy code. I would also suggested whether is possible to move the logic to the code behind , perhaps when the page loads?

I do assume the page is encapsulated into

<asp:Content ID="content" runat="server">

Upvotes: 1

Related Questions