2013-04-05 152 views
0

我是新來的asp.net,並面臨一些小問題。問題是將Textboxlabel設置在不同的位置,雖然我使用<br/>標籤,但表格看起來非常糟糕,我該如何解決流程問題?文本框和標籤位置問題

代碼:

<tr> 
     <td align="right" style="padding-right: 5px;" class="style6"> 
      <asp:Label ID="lblEmailId" runat="server" Text="EMAIL ID &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:"></asp:Label> 
     </td> 
     <td align="left" style="padding-left: 5px;" class="style6"> 
     <br/><br/><br/> 
     <asp:TextBox ID="txtEmailId" runat="server" Width="70%" AutoCompleteType="Office"></asp:TextBox> 
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtEmailId" 
       ErrorMessage="You can't leave this empty." Style="color: #FF0000;"></asp:RequiredFieldValidator> 

      <asp:RegularExpressionValidator ID="rfvEmailId" runat="server" ControlToValidate="txtEmailId" 
       ErrorMessage="Not a Valid Email Address" SetFocusOnError="True" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
       ValidationGroup="CreateUserWizard1" Style="color: #FF0000;" />&nbsp;<br /> 
      &nbsp; 
     </td> 
    </tr> 
    <tr> 
     <td colspan="2"> 
      <br /> 
     </td> 
    </tr> 
    <tr> 
     <td align="right" style="padding-right: 5px; " class="style6"> 
      <asp:Label ID="lblPhoneNo" runat="server" Text="PHONE NO.&nbsp;&nbsp;:"></asp:Label> 
     </td> 
     <td align="left" style="padding-left: 5px; " class="style6"> 
      <asp:TextBox ID="txtPhoneNo" runat="server" Width="70%" AutoCompleteType="Office"></asp:TextBox> 
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtPhoneNo" 
       ErrorMessage="You can't leave this empty." Style="color: #FF0000;"></asp:RequiredFieldValidator> 

      <asp:RegularExpressionValidator ID="rfvPhoneNo" ControlToValidate="txtPhoneNo" ValidationExpression="\d{10}" 
       ErrorMessage="The number must be 10 numeric digits!" runat="server" Style="color: #FF0000;" /> 
     </td> 
    </tr> 

PLZ任何一個可以幫助我在此流程...,

+2

一個sugesstion首先學習'HTML/Css',內聯css是BAD練習。請參閱http://www.w3schools.com/ – 2013-04-05 07:27:54

回答

0
  1. 擺脫<br />&nbsp;標籤。
  2. 設置的RequiredFieldValidator和的RegularExpressionValidator動態顯示

    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtEmailId" 
         ErrorMessage="You can't leave this empty." Style="color: #FF0000;" Display="Dynamic"></asp:RequiredFieldValidator> 
    <asp:RegularExpressionValidator ID="rfvEmailId" runat="server" ControlToValidate="txtEmailId" 
         ErrorMessage="Not a Valid Email Address" SetFocusOnError="True" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
         ValidationGroup="CreateUserWizard1" Style="color: #FF0000;" Display="Dynamic"/> 
    
0

刪除<br/><br/><br/>

而且真的,不要用設計師的佈局!僅將它用於預覽並添加新的自定義控件。

+1

如果我刪除
標記文本框正在向上移動它不是很面對標籤。 – BHARATH 2013-04-05 07:20:04

+0

對不起,我不明白你所說的事情, – BHARATH 2013-04-05 07:24:47

+0

你是什麼意思的「不同的位置」?它應該如何定位? – Rover 2013-04-05 07:26:58

1

在同一<tr>元件發生在其他例如在一個<td>標籤和文本框:

<table> 
    <tr> 
     <td> 
     Name 
     </td> 
     <td> 
     <asp:TextBox ID="txtName" runat="server" /> 
     </td> 
    </tr> 
    <tr> 
     <td> 
     Surname 
     </td> 
     <td> 
     <asp:TextBox ID="txtSurname" runat="server" /> 
     </td> 
    </tr> 
    <tr> 
     <td> 
     Age 
     </td> 
     <td> 
     <asp:TextBox ID="txtAge" runat="server" /> 
     </td> 
    </tr> 
    <tr> 
     <td colspan="2" style="text-align: right;"> 
     <asp:Button ID="btnAdd" runat="server" Text="Add" /> 
     </td> 
    </tr> 
</table> 

可生產以下佈局:

enter image description here