473,410 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

Validator & Layout problem

hey

asp.net 2.0

I'm trying to create a web page where users can register to my web portal.
But I've run into a layout problem when using the data validator classes.
The problem is that the error message is not displayed on the same row as
the control it's validating. Check this link and you see an example of the
problem: http://home.online.no/~au-holme/pub/14506/problem.GIF the text
"Password and confirm password must match" is not displayed on the same row
as the control it is set to validate. And also the error isn't left
aligned, but HorizontalAlign is set to "Left" - so I hoped the text should
be left aligned

What am I doing wrong here?

Below are the markup of my problem table

<asp:Table ID="Table1" runat="server" CellPadding="2" Width="100%"
BorderStyle="Solid" BorderColor="Green" BorderWidth="2">
<asp:TableRow>
<asp:TableCell CssClass="fieldname"
Width="180">UserName:</asp:TableCell>
<asp:TableCell Width="200" ><asp:TextBox ID="UserName" runat="server"
Width="200" /></asp:TableCell>
<asp:TableCell HorizontalAlign="Left" Width="220px">
<asp:RequiredFieldValidator ID="valRequireUserName" runat="server"
ControlToValidate="UserName" SetFocusOnError="true" Display="Dynamic"
ErrorMessage="Username is required." ToolTip="Username is required."
ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell CssClass="fieldname" Width="180" BorderStyle="Solid"
BorderColor="BlueViolet" BorderWidth="2">Password:</asp:TableCell>
<asp:TableCell Width="200" BorderStyle="Solid" BorderWidth="2"
BorderColor="DarkRed"><asp:TextBox ID="Password" runat="server"
TextMode="Password" Width="200" /></asp:TableCell>
<asp:TableCell HorizontalAlign="Left" Width="220px">
<asp:RequiredFieldValidator ID="valRequiredPassword" runat="server"
ErrorMessage="Password is required" ValidationGroup="CreateUserWizard1"
ControlToValidate="password"></asp:RequiredFieldValidator>
<%--<asp:RegularExpressionValidator ID="valPasswordLength" runat="server"
ErrorMessage="Password too short" Display="Dynamic"
ValidationGroup="CreateUserWizard1" ControlToValidate="Password"
ValidationExpression="\w{5,}"></asp:RegularExpressionValidator>--%>
</asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell CssClass="fieldname" Width="180">Confirm
password:</asp:TableCell>
<asp:TableCell Width="200" BorderStyle="Solid" BorderColor="CadetBlue"
BorderWidth="2"><asp:TextBox ID="Confirmpassword" runat="server"
TextMode="Password" Width="200" /></asp:TableCell>
<asp:TableCell HorizontalAlign="Left" Width="220px" BorderStyle="Solid"
BorderColor="Beige" BorderWidth="2">
<asp:RequiredFieldValidator ID="valRequiredConfirmPassword" runat="server"
ErrorMessage="Confirm password is required"
ControlToValidate="Confirmpassword"
ValidationGroup="CreateUserWizard1"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="valComparePasswords" runat="server"
ErrorMessage="Password and confirm password must match"
ValidationGroup="CreateUserWizard1" ControlToCompare="Password"
SetFocusOnError="true"
ControlToValidate="Confirmpassword"></asp:CompareValidator>
</asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell CssClass="fieldname" Width="180" BorderColor="Red"
BorderStyle="Solid" BorderWidth="2">E-mail:</asp:TableCell>
<asp:TableCell Width="200"><asp:TextBox ID="Email" runat="server"
Width="200" /></asp:TableCell>
<asp:TableCell>
<asp:RequiredFieldValidator ID="valRequireEmail" runat="server"
ErrorMessage="E-mail is required" ControlToValidate="Email"
ValidationGroup="CreateUserWizard1"
SetFocusOnError="true"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="valEmailPattern" runat="server"
ErrorMessage="The E-mail is not well-formed" Display="Dynamic"
ControlToValidate="Email" ValidationGroup="CreateUserWizard1"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell CssClass="fieldname" Width="180">Security
question:</asp:TableCell>
<asp:TableCell Width="200"><asp:TextBox ID="Question" runat="server"
Width="200" /></asp:TableCell>
<asp:TableCell>
<asp:RequiredFieldValidator ID="valRequireQuestion" runat="server"
ErrorMessage="Security question is required"
ValidationGroup="CreateUserWizard1" ControlToValidate="Question"
SetFocusOnError="true" Display="Dynamic"></asp:RequiredFieldValidator>
</asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell CssClass="fieldname" Width="180" BorderColor="Brown"
BorderStyle="Solid" BorderWidth="2">Security answer:</asp:TableCell>
<asp:TableCell Width="200"><asp:TextBox ID="Answer" runat="server"
Width="200" /></asp:TableCell>
<asp:TableCell>
<asp:RequiredFieldValidator ID="valRequireAnswar" runat="server"
ErrorMessage="Security answer is required" Display="Dynamic"
SetFocusOnError="true" ValidationGroup="CreateUserWizard1"
ControlToValidate="Answer"></asp:RequiredFieldValidator>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
Nov 9 '06 #1
1 2091
I've solved it, well I had to redesign the layout.
"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:ei**************@TK2MSFTNGP03.phx.gbl...
hey

asp.net 2.0

I'm trying to create a web page where users can register to my web portal.
But I've run into a layout problem when using the data validator classes.
The problem is that the error message is not displayed on the same row as
the control it's validating. Check this link and you see an example of the
problem: http://home.online.no/~au-holme/pub/14506/problem.GIF the text
"Password and confirm password must match" is not displayed on the same
row as the control it is set to validate. And also the error isn't left
aligned, but HorizontalAlign is set to "Left" - so I hoped the text should
be left aligned

What am I doing wrong here?

Below are the markup of my problem table

<asp:Table ID="Table1" runat="server" CellPadding="2" Width="100%"
BorderStyle="Solid" BorderColor="Green" BorderWidth="2">
<asp:TableRow>
<asp:TableCell CssClass="fieldname"
Width="180">UserName:</asp:TableCell>
<asp:TableCell Width="200" ><asp:TextBox ID="UserName" runat="server"
Width="200" /></asp:TableCell>
<asp:TableCell HorizontalAlign="Left" Width="220px">
<asp:RequiredFieldValidator ID="valRequireUserName" runat="server"
ControlToValidate="UserName" SetFocusOnError="true" Display="Dynamic"
ErrorMessage="Username is required." ToolTip="Username is required."
ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell CssClass="fieldname" Width="180" BorderStyle="Solid"
BorderColor="BlueViolet" BorderWidth="2">Password:</asp:TableCell>
<asp:TableCell Width="200" BorderStyle="Solid" BorderWidth="2"
BorderColor="DarkRed"><asp:TextBox ID="Password" runat="server"
TextMode="Password" Width="200" /></asp:TableCell>
<asp:TableCell HorizontalAlign="Left" Width="220px">
<asp:RequiredFieldValidator ID="valRequiredPassword" runat="server"
ErrorMessage="Password is required" ValidationGroup="CreateUserWizard1"
ControlToValidate="password"></asp:RequiredFieldValidator>
<%--<asp:RegularExpressionValidator ID="valPasswordLength" runat="server"
ErrorMessage="Password too short" Display="Dynamic"
ValidationGroup="CreateUserWizard1" ControlToValidate="Password"
ValidationExpression="\w{5,}"></asp:RegularExpressionValidator>--%>
</asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell CssClass="fieldname" Width="180">Confirm
password:</asp:TableCell>
<asp:TableCell Width="200" BorderStyle="Solid" BorderColor="CadetBlue"
BorderWidth="2"><asp:TextBox ID="Confirmpassword" runat="server"
TextMode="Password" Width="200" /></asp:TableCell>
<asp:TableCell HorizontalAlign="Left" Width="220px" BorderStyle="Solid"
BorderColor="Beige" BorderWidth="2">
<asp:RequiredFieldValidator ID="valRequiredConfirmPassword" runat="server"
ErrorMessage="Confirm password is required"
ControlToValidate="Confirmpassword"
ValidationGroup="CreateUserWizard1"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="valComparePasswords" runat="server"
ErrorMessage="Password and confirm password must match"
ValidationGroup="CreateUserWizard1" ControlToCompare="Password"
SetFocusOnError="true"
ControlToValidate="Confirmpassword"></asp:CompareValidator>
</asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell CssClass="fieldname" Width="180" BorderColor="Red"
BorderStyle="Solid" BorderWidth="2">E-mail:</asp:TableCell>
<asp:TableCell Width="200"><asp:TextBox ID="Email" runat="server"
Width="200" /></asp:TableCell>
<asp:TableCell>
<asp:RequiredFieldValidator ID="valRequireEmail" runat="server"
ErrorMessage="E-mail is required" ControlToValidate="Email"
ValidationGroup="CreateUserWizard1"
SetFocusOnError="true"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="valEmailPattern" runat="server"
ErrorMessage="The E-mail is not well-formed" Display="Dynamic"
ControlToValidate="Email" ValidationGroup="CreateUserWizard1"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell CssClass="fieldname" Width="180">Security
question:</asp:TableCell>
<asp:TableCell Width="200"><asp:TextBox ID="Question" runat="server"
Width="200" /></asp:TableCell>
<asp:TableCell>
<asp:RequiredFieldValidator ID="valRequireQuestion" runat="server"
ErrorMessage="Security question is required"
ValidationGroup="CreateUserWizard1" ControlToValidate="Question"
SetFocusOnError="true" Display="Dynamic"></asp:RequiredFieldValidator>
</asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell CssClass="fieldname" Width="180" BorderColor="Brown"
BorderStyle="Solid" BorderWidth="2">Security answer:</asp:TableCell>
<asp:TableCell Width="200"><asp:TextBox ID="Answer" runat="server"
Width="200" /></asp:TableCell>
<asp:TableCell>
<asp:RequiredFieldValidator ID="valRequireAnswar" runat="server"
ErrorMessage="Security answer is required" Display="Dynamic"
SetFocusOnError="true" ValidationGroup="CreateUserWizard1"
ControlToValidate="Answer"></asp:RequiredFieldValidator>
</asp:TableCell>
</asp:TableRow>
</asp:Table>

Nov 9 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

40
by: Woolly Mittens | last post by:
I was asked to find some documentation which explains how to develop a website using DIV's and CSS, instead of TABLES. This is to explain to the people we outsource things to, how we want it done....
72
by: Mel | last post by:
Are we going backwards ? (please excuse my spelling...) In my opinion an absolute YES ! Take a look at what we are doing ! we create TAGS, things like <H1> etc. and although there are tools...
17
by: Colin Cogle | last post by:
------- Line 47, column 8: there is no attribute "id" <DIV id="LeftNavigation" style="position:absolute; left:8px; top:6px; width:200p ------- Line 47, column 31: there is no attribute "style"...
39
by: Zak McGregor | last post by:
Hi all Are there any good solutions to aligning form field names and input boxes without resorting to tables? I am struggling to do this nicely at the moment. Thanks Ciao Zak
4
by: Milan | last post by:
Hi, I am having a problem with displaying a * to a required field. There seems to be a problem with this and the static value does not appear unless you submit the page. I am trying to display...
3
by: Angelos Karantzalis | last post by:
Hi guys, I've a small problem with validators. I'm building a single .aspx file that handles all my form posts. I need to be using ASP.NET validators ( or subclasses thereof ), so what i do to...
7
by: Andrew | last post by:
I've been struggling to achieve the following layout for some time now and I'm not getting anywhere. I've tried several approaches including floats & absolute positioning and none seem to work,...
11
by: toton | last post by:
Hi, I have little confusion about static memory allocation & dynamic allocation for a cluss member. I have class like class Bar{ public: explicit Bar(){ cout<<"bar default"<<endl; }
0
by: | last post by:
I have several textboxes for entering data, and when the user enters a value in one textbox, using the TextChanged event, the other textboxes are calculated with various types of calculations. ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.