locked
Visual Studio 2013 Odd behavior RRS feed

  • Question

  • User1241411908 posted

    Hi all,

    I started a new ASP.NET Web forms project

    I added a master page, followed by a CSS file(ttt.css) and a Webform. I placed the ttt.css file in a folder called CSS.

    I have not added anything to the Master page (yet). Currently it is the default that VS creates.

    My webform contains 9 buttons. The code follows:

    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
                <link href= "css/ttt.css" rel="stylesheet" type="text/css" />
    
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    
       <div class="button-container">
           <asp:Button ID="btnSq1" class="button-style" runat="server" Text="Button" />
           <asp:Button ID="btnSq2" class="button-style" runat="server" Text="Button" />
           <asp:Button ID="btnSq3" class="button-style" runat="server" Text="Button" />
           <asp:Button ID="btnSq4" class="button-style" runat="server" Text="Button" />
           <asp:Button ID="btnSq5" class="button-style" runat="server" Text="Button" />
           <asp:Button ID="btnSq6" class="button-style" runat="server" Text="Button" />
           <asp:Button ID="btnSq7" class="button-style" runat="server" Text="Button" />
           <asp:Button ID="btnSq8" class="button-style" runat="server" Text="Button" />
           <asp:Button ID="btnSq9" class="button-style" runat="server" Text="Button" />
        </div> 
    </asp:Content>

    And my CSS file:

     .button-container {
        width: 700px;
        background: gray;
        overflow-y: auto;
        ; top: 50%; left: 50%; transform: translate(-50%, -50%);
     }    
    
    
     .button-style {
        width: 200px;
        height: 200px;
        float: left;
        background: lightblue;   
        font-size: 20px;
        margin: 15px;
      }

    When I "run" the project in Internet Explorer it displays the following:

    https://drive.google.com/file/d/0BwHoDS_llfwSYXozNlZ1YnpxWmM/view

    (Image will be removed sometime later in 2016)

    That is what I want, so far so good!

    Now I change anything in the CSS file, for example, in the .button-style margin property from 15 to 5 px. I then "run" the project again and I get a directory listing!

    This usually indicates a permissions issue, but why did it work the first time? Why not when I change something in the CSS file?

    Now I go back to the code and in the ASPX file comment out the link that references the CSS file, or I simply change the name of the css file to something invalid and rerun the project. I now get a row of buttons without the formatting. I then go back to the code and uncomment the link line or fix the CSS file name, run again and I get the buttons in the layout as illustrated in the above link image, taking into account the latest change in the CSS file.

    And there you have it. Every time I change the CSS file and run it I get the directory listing. I then remove or invalidate the CSS link, run it, exit, go back and fix the link statement, run it again and it works again, reflecting the change in the CSS file. This behavior is so odd that I can't seem to narrow down a good search phrase..  I even scrapped the project and redid it again and I still get the same behavior. I've done previous projects and none have exhibited this behavior before. Does anyone have a clue? Or possible recommendations? I really appreciate the time taken to read this and for any orientation. Thanks! Saga

    Update:

    On a hunch I removed all style formatting from the Button tags and the Div on my ASPX. Resulting in the following code:

       <div>
           <asp:Button ID="btnSq1" runat="server" Text="Button" />
           <asp:Button ID="btnSq2" runat="server" Text="Button" />
           <asp:Button ID="btnSq3" runat="server" Text="Button" />
           <asp:Button ID="btnSq4" runat="server" Text="Button" />
           <asp:Button ID="btnSq5" runat="server" Text="Button" />
           <asp:Button ID="btnSq6" runat="server" Text="Button" />
           <asp:Button ID="btnSq7" runat="server" Text="Button" />
           <asp:Button ID="btnSq8" runat="server" Text="Button" />
           <asp:Button ID="btnSq9" runat="server" Text="Button" />
        </div> 

    It ran fine, without any formatting, of course. I then changed the CSS file, ran it and again I got the directory listing. I then went back and added the class to the Div and Button tags, ran it again and it worked fine. After more testing I concluded the following:

    When I modify the CSS file, even adding a comment, and run the site the directory listing comes up.

    After the directory listing comes up, if I modify anything in the ASPX file, and run, the correct content is presented

    Modifying the CSS after the directory listing come up does not change anything. It is only after I modify the ASP file that the correct content is displayed

    Exiting VS and opening the project again does not fix the problem

    Even adding a comment in the ASPX file, after the directory listing comes up, will fix it.

    Editing the CSS file and then editing the ASPX and then running the project will cause the correct content to display.

    This is so bizarre!

    Sunday, March 20, 2016 1:30 AM

Answers

  • User475983607 posted

    Right click on the aspx file and select "Set As Start Page".  

    More than likely the CSS file is the active tab.  Running the app causes VS to open the current folder (CSS) but it can't find a default page so it show a directory listing.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 20, 2016 11:46 AM

All replies

  • User475983607 posted

    Right click on the aspx file and select "Set As Start Page".  

    More than likely the CSS file is the active tab.  Running the app causes VS to open the current folder (CSS) but it can't find a default page so it show a directory listing.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 20, 2016 11:46 AM
  • User1241411908 posted

    Amazing! I set the ASPX file as start page and this resolved my problem. I was so certain that the ASPX was my start page. I might have missed it entirely. Thanks! Your recommendation was spot on! Saga

    Sunday, March 20, 2016 6:36 PM