Required field validator problem

  • Thread starter Thread starter Do
  • Start date Start date
D

Do

Hi,

Has anybody run into problems with Page.IsValid?
My errors show up when the fields aren't filled correctly, but my
processing continues even if the page is invalid.

I leave name and description blank and I do get the error messages. But
the code still continues to run the addfolder method from my class.

Is there something wrong with this?

Here's the code:

Dim strName As String

Dim strDescription As String

Dim intParent As Integer

strName = txtName.Text

strDescription = txtDescription.Text

intParent = lstParents.SelectedValue

Response.Write(strName)

Response.Write(strDescription)

Response.Write(intParent)

If Page.IsValid Then

Try

Dim objFolder As New folder

If CBool(objFolder.addfolder(strName, strDescription, intParent)) Then

Response.Write("Inserted new folder")

Else

Response.Write("Problem with folder insertion")

End If

objFolder = Nothing

Catch ex As Exception

Response.Write(ex.Message)

End Try

End If
 
Hi,

For server-side code, you need to call Page.Validate() before you test
Page.IsValid.

For more information, see ASP.NET Validation in Depth
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html
/aspplusvalid.asp

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

This posting is provided "AS IS", with no warranties, and confers no rights.


--------------------
 
Hi:

So what's the difference between Page.IsValid and Page.Validate and the
different
scenarios for their use?

So if I only use Page.IsValid, this will only do client-side validation?
If Page.IsValid does not return true, doesn't the nested code not process?
Mine seems like it processes.


Do


"Mike Moore [MSFT]" said:
Hi,

For server-side code, you need to call Page.Validate() before you test
Page.IsValid.

For more information, see ASP.NET Validation in Depth
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html
/aspplusvalid.asp

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer's security.

This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
From: "Do" <[email protected]>
Subject: Required field validator problem
Date: Mon, 20 Oct 2003 22:24:20 -0700
Lines: 58
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: adsl-66-120-230-110.dsl.lsan03.pacbell.net 66.120.230.110
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:185460
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Hi,

Has anybody run into problems with Page.IsValid?
My errors show up when the fields aren't filled correctly, but my
processing continues even if the page is invalid.

I leave name and description blank and I do get the error messages. But
the code still continues to run the addfolder method from my class.

Is there something wrong with this?

Here's the code:

Dim strName As String

Dim strDescription As String

Dim intParent As Integer

strName = txtName.Text

strDescription = txtDescription.Text

intParent = lstParents.SelectedValue

Response.Write(strName)

Response.Write(strDescription)

Response.Write(intParent)

If Page.IsValid Then

Try

Dim objFolder As New folder

If CBool(objFolder.addfolder(strName, strDescription, intParent)) Then

Response.Write("Inserted new folder")

Else

Response.Write("Problem with folder insertion")

End If

objFolder = Nothing

Catch ex As Exception

Response.Write(ex.Message)

End Try

End If
 
Hi,

Page.Validate calls the method the runs your validation code. Page.IsValid
tests the results of the validation. I suspect that you are submitting the
form with a control that does not cause validation. In this case, you must
call Page.Validate explicitly in your code. Then you can test the value of
Page.IsValid.

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

This posting is provided "AS IS", with no warranties, and confers no rights.


--------------------
Subject: Re: Required field validator problem
Date: Tue, 21 Oct 2003 17:23:20 -0700
Lines: 119
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#qt7#[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: adsl-66-121-42-242.dsl.lsan03.pacbell.net 66.121.42.242
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:185660
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Hi:

So what's the difference between Page.IsValid and Page.Validate and the
different
scenarios for their use?

So if I only use Page.IsValid, this will only do client-side validation?
If Page.IsValid does not return true, doesn't the nested code not process?
Mine seems like it processes.


Do


"Mike Moore [MSFT]" said:
Hi,

For server-side code, you need to call Page.Validate() before you test
Page.IsValid.

For more information, see ASP.NET Validation in Depth
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html
/aspplusvalid.asp

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer's security.

This posting is provided "AS IS", with no warranties, and confers no rights.
 
Back
Top