2017-02-12 78 views
0

大家 有一些奇怪的在我的網頁,因爲它每個控制器刪除多餘的線條ASP.Net

<asp:Label ID="ll" Class="question_bold" runat="server" Text="label 1" Visible="false"></asp:Label> 
    <asp:RequiredFieldValidator runat="server" id="lln" controltovalidate="Textbox" errormessage="* Required" Font-Bold="True" ForeColor="Red" SetFocusOnError="True" Display="Dynamic" /> 
    <asp:TextBox ID="Textbox" runat="server" Visible ="false" Width="350px" ></asp:TextBox> 
    <asp:LinkButton ID="check" CssClass="myclass" visible="false" runat="server" OnClick="check_Click">Check</asp:LinkButton> 

後會自動將新線和這裏的CSS代碼:

a.myclass{ color: #FF0000; text-decoration: none; } 
a.myclass:hover { text-decoration: none; } 

.question_bold { 
    font-weight: bold; 
    border: 1px solid #e6e6e6; 
    border-radius: 10px; 
    background-color: #e6e6e6; 
    height: 25px; 
    width: 100%; 
    display: block; 
} 

我試過改變顯示,甚至從ASP刪除整個CSS,但仍然是相同的 我需要文本框,字段驗證器,鏈接按鈕,以在同一行.... 任何想法?!

enter image description here

+0

你有佈局?你能包括一張圖片什麼是不需要的線? – Valkyrie

+0

該文本框應該有鏈接按鈕旁邊的「檢查」,然後現場驗證器 –

+0

瀏覽器開發工具是要走的路。只是「檢查元素」,看看會發生什麼 – jazzcat

回答

1

以下的代碼排隊在一行上的控件。它使用CSS3 flexbox排列控件。

<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head runat="server"> 
     <title></title> 
     <style> 
      a.myclass{ color: #FF0000; text-decoration: none; } 
      a.myclass:hover { text-decoration: none; } 

      .question_bold { 
       font-weight: bold; 
       border: 1px solid #e6e6e6; 
       border-radius: 10px; 
       background-color: #e6e6e6; 
       height: 25px; 
       width: 100%; 
       display: block; 
      } 

      .flex-container { 
       display: flex; 
       width: 650px; 
       height: 250px; 
      } 

      .flex-item { 
       height: 100px; 
       margin: 10px; 
      } 
     </style> 
    </head> 
    <body> 
     <form id="form1" runat="server"> 

     <div class="flex-container"> 
      <div class="flex-item"><asp:Label ID="ll" Class="question_bold" runat="server" Text="label 1"></asp:Label></div> 
      <div class="flex-item"><asp:RequiredFieldValidator runat="server" id="lln" controltovalidate="Textbox" errormessage="* Required" Font-Bold="True" ForeColor="Red" SetFocusOnError="True" Display="Dynamic" /></div> 
      <div class="flex-item"><asp:TextBox ID="Textbox" runat="server" Width="350px" ></asp:TextBox></div> 
      <div class="flex-item"><asp:LinkButton ID="check" CssClass="myclass" runat="server" OnClick="check_Click">Check</asp:LinkButton></div> 
     </div> 
     </form> 
    </body> 
    </html> 

上述解決方案需要瀏覽器支持CSS3 flexbox。你可以設置每個控件的寬度嗎?這也可以使用CSS完成。下面的解決方案適用於不同的瀏覽器。

 <div> 
      <span><asp:Label ID="ll" Class="question_bold" runat="server" Text="label 1" Width="100px"></asp:Label></span> 
      <span><asp:RequiredFieldValidator runat="server" id="lln" controltovalidate="Textbox" errormessage="* Required" Font-Bold="True" ForeColor="Red" SetFocusOnError="True" Display="Dynamic" /></span> 
      <span><asp:TextBox ID="Textbox" runat="server" Width="350px" ></asp:TextBox></span> 
      <span><asp:LinkButton ID="check" CssClass="myclass" runat="server">Check</asp:LinkButton></span> 
     </div> 
+0

不知何故,它只能在隱身模式(而不是Chrome或Firefox或IE)上使用chrome進行工作,只是在Chrome中隱身了......而且我認爲它不應該從第一行開始放置一個CSS來收集它們! –

+0

第一個解決方案需要瀏覽器支持CSS3 flexbox。我的其他解決方案是否解決您的問題 –

+0

flexbox在清除緩存和處理控制器寬度後工作得很好....感謝您的幫助 –

1

<html> 
 
    <head> 
 
     <title> </title> 
 

 
    </head> 
 
    <body> 
 
         
 
             <table class="format1" width="740px" cellpadding="2" cellspacing="0"> 
 
            <tr> 
 
             <td> 
 
              <asp:Label ID="ll" Class="question_bold" runat="server" Text="label 1" Visible="false"></asp:Label> 
 
              <asp:RequiredFieldValidator runat="server" ID="lln" ControlToValidate="Textbox" ErrorMessage="* Required" Font-Bold="True" ForeColor="Red" SetFocusOnError="True" Display="Dynamic" /> 
 
             </td> 
 

 
             <td> 
 
              <asp:TextBox ID="Textbox" runat="server" Visible="false" Width="350px"></asp:TextBox> 
 
             </td> 
 

 

 
             <td> 
 
              <asp:LinkButton ID="check" CssClass="myclass" Visible="false" runat="server" OnClick="check_Click">Check</asp:LinkButton> 
 

 
             </td> 
 

 
            </tr> 
 

 
           </table> 
 
     </body> 
 

 
     </html>