473,574 Members | 14,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mental Block - probably easy answer...valida tion summary

Hi all,

I have a login page which has username and password fields, a login button,
and 2 validation controls (one for each field) - currently I have controls
to display to the summary if the items missing etc.all working fine...

However, when the user logs in I fire off to a stored procedure, at this
point, unless the login is successful I can return up to about 8 different
error numbers in a string which I then split out into an array...

What I'd normally do in 'vanilla' ASP would be to iterate through the return
array and display a set of <tr><td></td></tr>'s etc for each error
message....I am at a complete loss as to how I do this in ASP.Net without
the use of labels?

Is it possible that I could add items to the validation summary at the
bottom of the page using my own error messages based on the returned error
code?

If not, how would I go about doing what i mentioned above, ie, producing
several rows in a table on the page? And if thats possible, would it also
be possible to remove the standard validation summary and upon the fields
being left empty, my table up top gets populated with the error messages
instead?

Any help would be apprecaited - and the easier to follow/understand the
better :o)

Many thanks for your time.

Regards

Rob
Nov 18 '05 #1
3 2330
How much work do you want to do?

The validation summary can be added to, but it is not a straightforward
process. It is facilitated by creating your own validation controls that
write out a message for the summary control. As the methodology is rather
standardized (which events fired, et al), you can hijack this functionality
to add your messages to the control by making a validation control.

On the other hand, you are creating functionality that is a bit kludgy when
you create a "validation control" that does not really validate, so the
label method is a working method. You can also set up a container control
(panel, et al) and add literals (which are lighter in client tags than the
label) to the container.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** *************** *************** *************** **********
Think Outside the Box!
*************** *************** *************** *************** **********
"Rob Meade" <ro**********@N OSPAMubht.swest .nhs.uk> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi all,

I have a login page which has username and password fields, a login button, and 2 validation controls (one for each field) - currently I have controls
to display to the summary if the items missing etc.all working fine...

However, when the user logs in I fire off to a stored procedure, at this
point, unless the login is successful I can return up to about 8 different
error numbers in a string which I then split out into an array...

What I'd normally do in 'vanilla' ASP would be to iterate through the return array and display a set of <tr><td></td></tr>'s etc for each error
message....I am at a complete loss as to how I do this in ASP.Net without
the use of labels?

Is it possible that I could add items to the validation summary at the
bottom of the page using my own error messages based on the returned error
code?

If not, how would I go about doing what i mentioned above, ie, producing
several rows in a table on the page? And if thats possible, would it also
be possible to remove the standard validation summary and upon the fields
being left empty, my table up top gets populated with the error messages
instead?

Any help would be apprecaited - and the easier to follow/understand the
better :o)

Many thanks for your time.

Regards

Rob

Nov 18 '05 #2
"Cowboy (Gregory A. Beamer)" wrote...
How much work do you want to do?
Not much! :D
The validation summary can be added to, but it is not a straightforward
process. It is facilitated by creating your own validation controls that
write out a message for the summary control. As the methodology is rather
standardized (which events fired, et al), you can hijack this functionality to add your messages to the control by making a validation control.

On the other hand, you are creating functionality that is a bit kludgy when you create a "validation control" that does not really validate, so the
label method is a working method. You can also set up a container control
(panel, et al) and add literals (which are lighter in client tags than the
label) to the container.

*WHOOOSH*

Ok - completely over my head all of that....

I'm currently looking at the add table row / table cell dynamically etc -
but even that wont work - grrr - even using the example in the help file
with Visual Studio and likewise on the MS site - I suspect I have to put a
IMPORTS at the top of the page or something - but as usual no mention is
made of this in the help :o(

Any ideas...

This is what I'm trying :

Dim tRow As New TableRow()
Table1.Rows.Add (tRow)

When I try to use this in my code - the Dim line REMOVES the brackets at the
end of TableRow

Then the second line has the purple scribble under tRow...

Not my day :(

Regards

Rob
Nov 18 '05 #3
Apologies for going over your head. It will become clear over time.

There are basically two ways to add items to a page like you describe.

1. Make your own validation control. This is the *whoosh* you described, as
it requires some understanding of derived classes.
2. Add your own controls to the page that handle the special messages.

I will examine #2, as that is what you are trying (comments inline):

"Rob Meade" <ro**********@N OSPAMubht.swest .nhs.uk> wrote in message
news:eq******** ******@tk2msftn gp13.phx.gbl...

I'm currently looking at the add table row / table cell dynamically etc -
but even that wont work - grrr - even using the example in the help file
with Visual Studio and likewise on the MS site - I suspect I have to put a
IMPORTS at the top of the page or something - but as usual no mention is
made of this in the help :o(

Any ideas...

This is what I'm trying :

Dim tRow As New TableRow()
Table1.Rows.Add (tRow)

When I try to use this in my code - the Dim line REMOVES the brackets at the end of TableRow


The disappearing () is quite normal with Visual Basic. The problem is you
have not added any cells to the row. Here is an example that uses a label to
render some text.

Dim tr As New TableRow
Dim tc As New TableCell
Dim lbl As New Label
lbl.Text = "This is some sample text"
tc.Controls.Add (lbl)
tr.Cells.Add(tc )
Table1.Rows.Add (tr)

NOTE: You can also use a literal.

Dim tr As New TableRow
Dim tc As New TableCell
tc.Controls.Add (New LiteralControl( "This is some sample text"))
tr.Cells.Add(tc )
Table1.Rows.Add (tr)

Literals are a little lighter, although you will not be able to position as
easily. As you are using a table, this is not a problem. NOTE that you could
do this a bit more longhand, if you wish:

Dim tr As New TableRow
Dim tc As New TableCell
Dim lit As new LiteralControl( "This is some sample text"))

tc.Controls.Add (New LiteralControl( lit)
tr.Cells.Add(tc )
Table1.Rows.Add (tr)

Do not get overdrawn on the specifics here, just play with the code and you
will feel more comfortable. You can now loop, for example, through a loop of
validation error messages, like so:

Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load

'Get validation errors
' Assuming an array here, have to alter for other forms
Dim aryString() As String = ValidateErrors( )

'Set up counter for the loop
Dim intCounter As Integer

For intCounter = 0 To UBound(aryStrin g)
Dim tr As New TableRow
Dim tc As New TableCell
tc.Controls.Add (New LiteralControl( aryString(intCo unter)))
tr.Cells.Add(tc )
Table1.Rows.Add (tr)
Next
End Sub

'NOTE: This is simply to test, create a true validation routine
' instead of this kludge
Private Function ValidateErrors( ) As String()
'Simple array; yours will come from validation
Dim outputString() As String = {"Validation error 1", _
"Validation error 2", "Validation Error 3"}

'Return the array for processing in Page_Load
Return outputString
End Function
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** *************** *************** *************** **********
Think Outside the Box!
*************** *************** *************** *************** **********
Nov 18 '05 #4

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

Similar topics

1
1418
by: craig | last post by:
I am having a mental block... What is the method for determining if an oject has been instantaited in C#? Ex: Dataset d; How can I tell if d has been instantiated?
1
3474
by: Tony | last post by:
Hi folks, I've got a bit of a problem. I have a situation where I build forms completely dynamically based on a form definition supplied from a database. Anyway, I noticed that required fields weren't validating on the server side, so I've whittled the code down to the example below which illustrates the problem. Basically, when I...
2
2785
by: Lucas Tam | last post by:
Hi all, I want to display an error message from a custom validator in my Validation Summary control. Do I need to build the ServerValidate Event handler in order to display an error message? All I wish to do is raise an error message on a failed database insert -
2
3718
by: Barbara Alderton | last post by:
I setup some standard Required Field Validation controls and one Custom validation control on an ASP.NET page (within a user control) to validate text entry. I also setup a Summary Control to post all the messages to a message box (ShowMessageBox=true). The required field validation error messages show up in the summary just fine but I can't...
1
14319
by: NancyASAP | last post by:
Thought I'd share this since it took me a long time to get it working. Thanks to a bunch of contributers in Google Groups who shared javascript, etc. The question was: How can I put a reset button on my ASP.NET web page, and have an HTML reset button click clear 1) all validator text display and 2) validation summary display. Problem was...
0
2865
by: Cleako | last post by:
Here is my dilema. I have a validation summary that I use soley for my Required Field Validators. I have it setup to run from a Page.Validate call in the code-behind, this is because I need to be able to clear text or other various functions need to be checked before it hits the back side. That works fine if I do things that way up to a...
1
1811
by: Buddy Ackerman | last post by:
I don't know what the problem is. I have a form with several controls that need to be validated, I put a validation group in every form control, every validatoino control, the submit button and the validation summary control. I want it to do client side validation so I set every validation control display property to none and set the...
5
4944
by: paul_zaoldyeck | last post by:
does anyone know how to validate an xml file against multiple defined schema? can you show me some examples? i'm making here an xml reader.. thank you
2
5222
by: nmakhan | last post by:
I have a validation summary that I use soley for my Required Field Validators. That works fine if I do things that way up to a point, if by chance the validation summary says "Date field required" then I edit the date and input an incorrect date, which I have a JavaScript validation for, that message will come up saying how to enter the...
0
7817
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7738
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8081
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7833
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8119
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5322
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3759
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3771
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2254
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.