473,500 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using Validation Controls with Page.ParseControl

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 possible?").
But looking deeper I run into a problem:

Kirk said, that "validation works as expected", but in my experience it
works only to a certain degree "as expected".

I test the server-side validation and disable JavaScript.
Now I 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, 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 11 '05 #1
0 2255

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

Similar topics

1
3383
by: Matthias Lohrer | last post by:
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...
4
2346
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
2790
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...
5
2385
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
3493
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
1389
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
2905
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
1810
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
1236
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
7136
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
7018
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
7232
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...
1
6906
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...
0
5490
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
4611
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...
0
3110
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...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
316
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.