2017-02-12 77 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>