Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello guys,

I am having an another issue with this web application I am making.

Unfortunately I can't understand why it is doing this.

HTML CODE
ASP.NET
<nav id="mobileonly" class="clearfix"  runat="server">
    <asp:Panel ID="mobileMenuP" runat="server"></asp:Panel>
		<a href="#" id="pull">Menu</a>
	</nav>

<div class="content">
    <div class="header">
        <asp:Panel CssClass="pure-menu pure-menu-open pure-menu-fixed pure-menu-horizontal" ID="headerMenu" runat="server">

            <div style="float: right; padding-removed 9px;" class="pure-form">
                <fieldset>

                    <asp:TextBox runat="server" ID="user_email" placeholder="Email" TextMode="Email" ></asp:TextBox>
                    <asp:TextBox runat="server" ID="user_password" placeholder="Password" TextMode="Password" ></asp:TextBox>

                    <asp:Button runat="server" Text="Sign in" ID="login_button" OnClick="login_button_Click" CssClass="pure-button pure-button-primary" />
                </fieldset>
            </div>
        </asp:Panel>
        </div>
    </div>


C# CODE
C#
List<HtmlGenericControl> parents = new List<HtmlGenericControl>();
//GET CONTROLS AND ADD TO parents.
//DEBUG: //Response.Write("PC: " + parents.Count);
            HtmlGenericControl[] parentsArr = parents.ToArray();
            HtmlGenericControl mainMenuMenu = new HtmlGenericControl("ul");
            for (int i = 0; i < parentsArr.Length; i++)
            {
                mainMenuMenu.Controls.Add(parentsArr[i]);
            }

            HtmlGenericControl mobileMenuMenu = mainMenuMenu;
            mobileMenuMenu.Attributes.Add("class", "clearfix");

            headerMenu.Controls.AddAt(0, mainMenuMenu);

            mobileonly.Controls.AddAt(0, mobileMenuMenu);


Now the problem I am having is that if I comment this line of code
C#
mobileonly.Controls.AddAt(0, mobileMenuMenu);

The headerMenu has no issue displaying the menu.

But when I un-comment it, all that is displayed in the headerMenu is


    and mobileonly has a menu displayed no problem.

    How the thing I don't understand is there isn't an error being thrown, the first isn't displaying anything but the second is which is backwards to programming logic.

    Any ideas would be awesome.

    Thanks
    Posted
    Comments
    Kornfeld Eliyahu Peter 24-Nov-13 13:33pm    
    Do you mean to put mobileMenuMenu BEFORE mainMenuMenu?
    M.R. Inc 24-Nov-13 13:39pm    
    Mobile menu doesn't display anything at all if I do that :(
    Kornfeld Eliyahu Peter 24-Nov-13 14:25pm    
    I looked - again - into your TestHome page and found a CSS rule #mobileonly{display:none;}
    M.R. Inc 24-Nov-13 14:28pm    
    I am not running this code on the TestHome.aspx

    Running on local at the moment.

    But it is only a mobile menu, so when the screen is less than a certain size, it will hide the main menu and show the mobile. I have published for you. - http://cykilic.mrincapps.co.za

    (Make your browser window mobile size and watch it change)

    Thanks
    Kornfeld Eliyahu Peter 24-Nov-13 14:28pm    
    And than found that it changes when I use small browser window size to imitate small mobile screen. It seems you have a media rule-set in your CSS that controls that. So if you have large screen the man menu shows, but on small screen it switches to the mobile menu...

    1 solution

    I was able to sort out the problem by creating 2 List Items from the start.

    I would preferred not to as it was really not necessary but it works no issue.
     
    Share this answer
     

    This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



    CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900