Search code examples
cssasp.netrunatserver

Page design changed when html moved to aspx page


I am facing a strange issue. I have a html page whose design is perfect but when I am copying the same to aspx then design got distorted. Now, when I removed

<form id="form1" runat="server"> and <head runat="server">

attribute then design got corrected.

I am not sure why this has happened and how can I fix that because I don't think it's a good idea to remove form tag from aspx page


Solution

  • I fixed this issue.

    Some of my CSS was referring to ID, when I changed it to class it started working as per my expectation.

    It is an important note for all ASP.NET webform developers: "Do styling with class only"

    Ex: #Myclass
    {
     height:10px;
    }
    
    <div id="divId" class="MyClass"></div>