文本框,标签位置的问题 [英] textbox and label position issue

查看:167
本文介绍了文本框,标签位置的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来asp.net和它面临着一些小问题。问题是设置文本框标签在不同的位置,而我用的是&LT ; BR /> 标记的形式看起来非常糟糕,我怎么能解决这个流程

code是:

 < TR>
        < TD ALIGN =正确的风格=填充右:为5px;类=灰色庄重>
            < ASP:标签ID =lblEmailId=服务器文本=电子邮件ID&放大器; NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP;>< / ASP:标签&gt ;
        < / TD>
        < TD align =left的风格=填充左:为5px;类=灰色庄重>
        < BR />< BR />< BR />
         < ASP:文本框ID =txtEmailId=服务器WIDTH =70%AutoCompleteType =办公室>< / ASP:文本框>
                        
            < ASP:的RequiredFieldValidator ID =RequiredFieldValidator1=服务器的ControlToValidate =txtEmailId
                的ErrorMessage =你不能离开这个空白。风格=COLOR:#FF0000;>< / ASP:&的RequiredFieldValidator GT;            < ASP:RegularEx pressionValidator ID =rfvEmailId=服务器的ControlToValidate =txtEmailId
                的ErrorMessage =无效的电子邮件地址SetFocusOnError =真ValidationEx pression =\\ w +([ - +'。] \\ w +)* @ \\ w +([ - ] \\ w +)* \\ \\ W +。 ([ - ] \\ w +)*
                的ValidationGroup =CreateUserWizard1风格=COLOR:#FF0000; />&安培; NBSP;< BR />
            &安培; NBSP;
        < / TD>
    < / TR>
    &所述; TR>
        &所述; TD列跨度=2>
            < BR />
        < / TD>
    < / TR>
    &所述; TR>
        < TD ALIGN =正确的风格=填充右:为5px;阶级=灰色庄重>
            < ASP:标签ID =lblPhoneNo=服务器文本=PHONE NO&放大器; NBSP;&安培; NBSP;>< / ASP:标签>
        < / TD>
        < TD align =left的风格=填充左:为5px;阶级=灰色庄重>
            < ASP:文本框ID =txtPhoneNo=服务器WIDTH =70%AutoCompleteType =办公室>< / ASP:文本框>
                        
            < ASP:的RequiredFieldValidator ID =RequiredFieldValidator2=服务器的ControlToValidate =txtPhoneNo
                的ErrorMessage =你不能离开这个空白。风格=COLOR:#FF0000;>< / ASP:&的RequiredFieldValidator GT;            < ASP:RegularEx pressionValidator ID =rfvPhoneNo的ControlToValidate =txtPhoneNoValidationEx pression =\\ D {10}
                的ErrorMessage =数必须是10位数字! =服务器风格=COLOR:#FF0000; />
        < / TD>
    < / TR>

PLZ任何一个可以帮助我在此流程...


解决方案

  1. 摆脱< BR /> &放大器; NBSP; 标记

  2. 设置的RequiredFieldValidator和RegularEx pressionValidator动态显示

     < ASP:的RequiredFieldValidator ID =RequiredFieldValidator1=服务器的ControlToValidate =txtEmailId
            的ErrorMessage =你不能离开这个空白。风格=COLOR:#FF0000;显示=动态>< / ASP:&的RequiredFieldValidator GT;
    < ASP:RegularEx pressionValidator ID =rfvEmailId=服务器的ControlToValidate =txtEmailId
            的ErrorMessage =无效的电子邮件地址SetFocusOnError =真ValidationEx pression =\\ w +([ - +'。] \\ w +)* @ \\ w +([ - ] \\ w +)* \\ \\ W +。 ([ - ] \\ w +)*
            的ValidationGroup =CreateUserWizard1风格=COLOR:#FF0000;显示=动态/>


I am new to asp.net and facing some small problem in it. Problem is to set the Textbox and label are in different position and while I use the <br/> tag the form is looking very bad how can I resolve the flow?

code is:

<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 can any one help me on this flow...,

解决方案

  1. get rid of <br /> and &nbsp; tags.
  2. set the RequiredFieldValidator and RegularExpressionValidator to dynamically display

    <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"/>
    

这篇关于文本框,标签位置的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆