473,386 Members | 1,726 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,386 software developers and data experts.

Using Validation Controls with Page.ParseControl

Hi,

I'm playing around with the possibilities of Page.ParseControl.
I parse a string with an input-field and an RequiredFieldValidator-control.

For testing the server-side validation I disable JavaScript
and get this scenario:

- When you enter a name, no warning appears, that's good!
- When you don't enter a name, the warning appears, that's very good!

So everything seems to be right.

But what, if you get the idea to check in your code, whether the form is
valid or not, by using "If Page.IsValid", perhaps this way:

---parsetest.aspx--- --- --- --- --- --- --- --- --- --- --- --- --- --- ---

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="parsetest.aspx.vb" Inherits="Xorum.parsetest" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>parsetest</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
</form>
<p runat="server" id="kommentar" ></p>
</body>
</html>
--- ---
parsetest.aspx.vb --- --- --- --- --- --- --- --- --- --- --- --- --- --- --

Public Class parsetest
Inherits System.Web.UI.Page
Protected form1 As System.Web.UI.HtmlControls.HtmlForm
Protected kommentar As System.Web.UI.HtmlControls.HtmlGenericControl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim s As String
s = "What is your name? <br><br><input runat='server' id='txtName'
type='text' ><asp:RequiredFieldValidator id='reqTxtName'
ControlToValidate='txtName' Display='dynamic' runat='server'>
Please enter your name.</asp:RequiredFieldValidator> <br><br><input
runat='server' type='submit' value=' OK ' ><br><br><asp:Label id='meldung'
runat='server' />"
form1.Controls.Add(Page.ParseControl(s))
If IsPostBack Then
Page.Validate()
If Page.IsValid Then
kommentar.InnerHtml &= "OK "
Else
kommentar.InnerHtml &= "Not OK "
End If
End If
End Sub
End Class
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---

This is the result:
The validation works correctly, but using "Page.IsValid" will ALWAYS return
false. Even if the
validation control works correctly and no warning appears, there will be the
message "Not OK "!!!
On the other side: When I use just this code, but don't use
Page.ParseControl, but
insert the code for the form and the validation-control right into the
aspx-Page, everything works
fine and Page.IsValid will always say correctly, whether the form is valid
or not.
Any idea?
Thank you
Matthias
Nov 17 '05 #1
1 3380
Hi
Before calling page.IsValid, you should call Page.Validate

Page.Validate
Page.IsValid

--
Thank you.

Satish Appasani
#201, Wing - 1, Block - D
Cyber Gateway
Hyderabad - 500 081, India
Phone: +91(40)2311-1356 Ext-122
Mobile: +91(40)333-31032
E-mail: sa****@vertexcs.com
"Matthias Lohrer" <ma*************@mlohrer.de> wrote in message
news:3f*********************@read.news.de.uu.net.. .
Hi,

I'm playing around with the possibilities of Page.ParseControl.
I parse a string with an input-field and an RequiredFieldValidator-control.
For testing the server-side validation I disable JavaScript
and get this scenario:

- When you enter a name, no warning appears, that's good!
- When you don't enter a name, the warning appears, that's very good!

So everything seems to be right.

But what, if you get the idea to check in your code, whether the form is
valid or not, by using "If Page.IsValid", perhaps this way:

---parsetest.aspx--- --- --- --- --- --- --- --- --- --- --- --- --- --- - --
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="parsetest.aspx.vb" Inherits="Xorum.parsetest" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>parsetest</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
</form>
<p runat="server" id="kommentar" ></p>
</body>
</html>
--- ---
parsetest.aspx.vb --- --- --- --- --- --- --- --- --- --- --- --- --- --- --
Public Class parsetest
Inherits System.Web.UI.Page
Protected form1 As System.Web.UI.HtmlControls.HtmlForm
Protected kommentar As System.Web.UI.HtmlControls.HtmlGenericControl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim s As String
s = "What is your name? <br><br><input runat='server' id='txtName'
type='text' ><asp:RequiredFieldValidator id='reqTxtName'
ControlToValidate='txtName' Display='dynamic' runat='server'>
Please enter your name.</asp:RequiredFieldValidator> <br><br><input
runat='server' type='submit' value=' OK ' ><br><br><asp:Label id='meldung'
runat='server' />"
form1.Controls.Add(Page.ParseControl(s))
If IsPostBack Then
Page.Validate()
If Page.IsValid Then
kommentar.InnerHtml &= "OK "
Else
kommentar.InnerHtml &= "Not OK "
End If
End If
End Sub
End Class
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---

This is the result:
The validation works correctly, but using "Page.IsValid" will ALWAYS return false. Even if the
validation control works correctly and no warning appears, there will be the message "Not OK "!!!
On the other side: When I use just this code, but don't use
Page.ParseControl, but
insert the code for the form and the validation-control right into the
aspx-Page, everything works
fine and Page.IsValid will always say correctly, whether the form is valid
or not.
Any idea?
Thank you
Matthias

Nov 17 '05 #2

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

Similar topics

0
by: Matthias Lohrer | last post by:
Hi, I'm playing around with the possibilities of Page.ParseControl. Thanks to Kirk Allen Evans I got my example running (Posting Juli, 17, "Re: Generating ASP.NET-Controls with XSLT...
4
by: | last post by:
Hello Guys, I am using the validation controls to validate my data. But the problem is "The page is still being posted to server". I want to get rid of the round trips to server. Are there...
4
by: Kevin Phifer | last post by:
Ok, before anyone freaks out, I have a solution I need to create that gathers content from maybe different places. Each one can return a <form> in the html, so its the classic can't have more than...
14
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2)...
5
by: mytestemailaccount | last post by:
Hi, Hope you can help. I am relatively new to all this but would appreciate the groups help. The scenario: I am c# and asp.net to create a web application. The web page contains a user...
5
by: Amelyan | last post by:
How can I get state of dynamically created controls (RadioButton, CheckBox, TextBox.Text) on post back when I click submit button? The only way I know is by traversing Response.Form enumberator;...
0
by: PB | last post by:
According to the documentation, ParseControl returns a parsed control from an input string. The documentation seems to assume that *one* control will be parsed from the string. My implementation...
21
by: matvdl | last post by:
I have a system that was originally developed in asp - the pages are saved in SQL (there are over 10,000 pages) and saved to a temp directory in the server when requested by a client. I have...
1
by: Jordan S. | last post by:
Using .NET 3.5, I'm wondering how to get a control's specific type (e.g,. "Button" and not simply "Control") after the control is inserted into a control hierarchy - when ParseControl is used. ...
2
by: anthonykallay | last post by:
Hi there, I have a built a CMS system that allows users to do all the usual functions (add/edit pages), what i would like is for the user to be able to be able to insert a pre defined control...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.