开发者

Validation in table control

Currently I'm doing a web form and added some textbox for users to insert into the database. It is working alright already, the validation seems to work successfully without any exception or errors. But I need to align the textbox to make it properly displayed on the browser (Mozilla FireFox).

The problem is, my validation IS IN THE TABLE seems not to be working and I keep encountering error that stated my textbox is null, when I clearly filled that textbox with the correct datatype.

Here is my code:

<table>

  <tr>
    <td>&nbsp;Customer name&nbsp;</td>
    <td><asp:TextBox ID="txtCustomerName0" runat="server" display="Dynamic" ValidationGroup="VG"></asp:TextBox></td>
    <td class="style1">
      <asp:RequiredFieldValidator ID="R开发者_运维问答equiredFieldValidator2" runat="server"
        ErrorMessage="This field must be filled in"
        ControlToValidate="txtCustomerName0"
        ValidationGroup="VG" Display="Dynamic"></asp:RequiredFieldValidator></td>
  </tr>

  <tr>
    <td>&nbsp;Contact&nbsp;</td>
    <td><asp:TextBox ID="txtContact0" runat="server" ValidationGroup="VG"></asp:TextBox></td>
    <td>
      <asp:CompareValidator ID="CompareValidator9" runat="server"
        ControlToValidate="txtContact0" ErrorMessage="Please put correct phone no."
        Operator="DataTypeCheck" Type="Integer"
        ValidationGroup="VG" Display="Dynamic"></asp:CompareValidator>
    </td>
  </tr>

  <tr>
    <td>ProductCode</td>
    <td><asp:TextBox ID="txtProductCode0" runat="server" ValidationGroup="VG"></asp:TextBox></td>
    <td>&nbsp;</td>
  </tr>

  <tr>
    <td>ProductName</td>
    <td><asp:TextBox ID="txtProductName0" runat="server" ValidationGroup="VG"></asp:TextBox></td>
    <td>&nbsp;</td>
  </tr>

  <tr>
    <td>Description</td>
    <td><asp:TextBox ID="txtDescription0" runat="server" ValidationGroup="VG"></asp:TextBox></td>
    <td>&nbsp;</td>
  </tr>

  <tr>
    <td>Address</td>
    <td><asp:TextBox ID="txtAddress0" runat="server" ValidationGroup="VG"></asp:TextBox></td>
    <td>&nbsp;</td>
  </tr>

  <tr>
    <td>Quantity</td>
    <td><asp:TextBox ID="txtQuantity0" runat="server" ValidationGroup="VG"></asp:TextBox></td>
    <td>
      <asp:CompareValidator ID="CompareValidator10" runat="server"
        ControlToValidate="txtQuantity0" ErrorMessage="Please put correct quantity"
        Operator="DataTypeCheck" Type="Integer"
        ValidationGroup="VG"></asp:CompareValidator>
    </td>
  </tr>

  <tr>
    <td>UnitSalePrice</td>
    <td><asp:TextBox ID="txtUnitSalePrice0" runat="server" ValidationGroup="VG"></asp:TextBox></td>
    <td>
      <asp:CompareValidator ID="CompareValidator11" runat="server"
        ControlToValidate="txtUnitSalePrice0" ErrorMessage="Please put correct price"
        Operator="DataTypeCheck" Type="Currency" 
        ValidationGroup="VG"></asp:CompareValidator>
    </td>
  </tr>

  <tr>
    <td>Amount</td>
    <td><asp:TextBox ID="txtAmount0" runat="server" ValidationGroup="VG"></asp:TextBox></td>
    <td>
      <asp:CompareValidator ID="CompareValidator12" runat="server"
        ControlToValidate="txtAmount0" ErrorMessage="Please put correct amount"
        Operator="DataTypeCheck" Type="Currency" 
        ValidationGroup="VG"></asp:CompareValidator>
    </td>
  </tr>

  <tr>
    <td>RequiredDate</td>
    <td><asp:TextBox ID="txtRequiredDate0" runat="server" ValidationGroup="VG"></asp:TextBox></td>
    <td>
      <asp:CompareValidator ID="CompareValidator13" runat="server"
        ControlToValidate="txtRequiredDate0"
        ErrorMessage="Please put correct date format" Operator="DataTypeCheck"
        Type="Date" ValidationGroup="VG"></asp:CompareValidator>
    </td>
  </tr>

  <tr>
    <td>ConfirmedDate</td>
    <td><asp:TextBox ID="txtConfirmedDate0" runat="server" ValidationGroup="VG"></asp:TextBox></td>
    <td>
      <asp:CompareValidator ID="CompareValidator14" runat="server"
        ControlToValidate="txtConfirmedDate0" 
        ErrorMessage="Please put correct date format" 
        Operator="DataTypeCheck" Type="Date" 
        ValidationGroup="VG"></asp:CompareValidator></td>
  </tr>

  <tr>
    <td><asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="ADD" ValidationGroup="VG" /></td>
    <td><asp:Button ID="btnBack0" runat="server" onclick="btnHome_Click" Text="Back" /></td>
    <td></td>
  </tr>

</table>


Use the "Width" property for the Alignment


Make css file for that. In the file add one class, for example:

.textbox
{
text-align:center;  
}

apply that cssclass="textbox" with you textbox and you will get textbox align.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜