473,473 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Login Control/Validation Summary within Content Placeholder

The background:
I have a web app with a simple master page that contains just one
content placeholder.

I have created a web form that then uses this master page. Within the
content placeholder, I have placed a Login control (Login1) and a
ValidationSummary control.

I have set the ValidationSummary's ValidationGroup property equal to
"Login1".

The problem:
The validation summary is not firing when a login textbox is left
blank.

What I have found:
I put the Login control and ValidationSummary control in a separate
page that uses no masterpage/content placeholders - and it works fine.
So it seems the issue begins with the master page/content involvement.

I looked at the HTML source on both pages and this throws up what I
think is causing the problem - but I'm not sure how to resolve it!

In the non-master page file, you get the following markup:

<script type="text/javascript">
<!--
var Login1_UserNameRequired = document.all ?
document.all["Login1_UserNameRequired"] :
document.getElementById("Login1_UserNameRequired") ;
Login1_UserNameRequired.controltovalidate = "Login1_UserName";
Login1_UserNameRequired.errormessage = "User Name is required.";
Login1_UserNameRequired.validationGroup = "Login1";
Login1_UserNameRequired.evaluationfunction =
"RequiredFieldValidatorEvaluateIsValid";
Login1_UserNameRequired.initialvalue = "";
var Login1_PasswordRequired = document.all ?
document.all["Login1_PasswordRequired"] :
document.getElementById("Login1_PasswordRequired") ;
Login1_PasswordRequired.controltovalidate = "Login1_Password";
Login1_PasswordRequired.errormessage = "Password is required.";
Login1_PasswordRequired.validationGroup = "Login1";
Login1_PasswordRequired.evaluationfunction =
"RequiredFieldValidatorEvaluateIsValid";
Login1_PasswordRequired.initialvalue = "";
var ValidationSummary1 = document.all ?
document.all["ValidationSummary1"] :
document.getElementById("ValidationSummary1");
ValidationSummary1.validationGroup = "Login1";
// -->
</script>

However, when I use the master page code, you get:

<script type="text/javascript">
<!--
var ctl00_ContentPlaceHolder1_Login1_UserNameRequired = document.all ?
document.all["ctl00_ContentPlaceHolder1_Login1_UserNameRequired "] :
document.getElementById("ctl00_ContentPlaceHolder1 _Login1_UserNameRequired");
ctl00_ContentPlaceHolder1_Login1_UserNameRequired. controltovalidate =
"ctl00_ContentPlaceHolder1_Login1_UserName";
ctl00_ContentPlaceHolder1_Login1_UserNameRequired. errormessage = "User
Name is required.";
ctl00_ContentPlaceHolder1_Login1_UserNameRequired. validationGroup =
"ctl00$ContentPlaceHolder1$Login1";
ctl00_ContentPlaceHolder1_Login1_UserNameRequired. evaluationfunction =
"RequiredFieldValidatorEvaluateIsValid";
ctl00_ContentPlaceHolder1_Login1_UserNameRequired. initialvalue = "";
var ctl00_ContentPlaceHolder1_Login1_PasswordRequired = document.all ?
document.all["ctl00_ContentPlaceHolder1_Login1_PasswordRequired "] :
document.getElementById("ctl00_ContentPlaceHolder1 _Login1_PasswordRequired");
ctl00_ContentPlaceHolder1_Login1_PasswordRequired. controltovalidate =
"ctl00_ContentPlaceHolder1_Login1_Password";
ctl00_ContentPlaceHolder1_Login1_PasswordRequired. errormessage =
"Password is required.";
ctl00_ContentPlaceHolder1_Login1_PasswordRequired. validationGroup =
"ctl00$ContentPlaceHolder1$Login1";
ctl00_ContentPlaceHolder1_Login1_PasswordRequired. evaluationfunction =
"RequiredFieldValidatorEvaluateIsValid";
ctl00_ContentPlaceHolder1_Login1_PasswordRequired. initialvalue = "";
var ctl00_ContentPlaceHolder1_ValidationSummary1 = document.all ?
document.all["ctl00_ContentPlaceHolder1_ValidationSummary1"] :
document.getElementById("ctl00_ContentPlaceHolder1 _ValidationSummary1");
ctl00_ContentPlaceHolder1_ValidationSummary1.valid ationGroup =
"ContentPlaceHolder1.Login1";
// -->
</script>

It seems that the ValidationGroup for the internal controls of the
Login control has been changed from "Login1" to
"ctl00$ContentPlaceHolder1$Login1" causing a mis-match between the
Login control and ValidationSummary.

Is there a way of rectifying this?

Many thanks in hope of a reply!!

Ian

Feb 27 '06 #1
3 5762
DWS
ilockett,
Error you are adding validation to the login control that does its own
validation. You have your design backwards or are doing something wrong.

Good Luck finding your error.
DWS

"ilockett" wrote:
The background:
I have a web app with a simple master page that contains just one
content placeholder.

I have created a web form that then uses this master page. Within the
content placeholder, I have placed a Login control (Login1) and a
ValidationSummary control.

I have set the ValidationSummary's ValidationGroup property equal to
"Login1".

The problem:
The validation summary is not firing when a login textbox is left
blank.

What I have found:
I put the Login control and ValidationSummary control in a separate
page that uses no masterpage/content placeholders - and it works fine.
So it seems the issue begins with the master page/content involvement.

I looked at the HTML source on both pages and this throws up what I
think is causing the problem - but I'm not sure how to resolve it!

In the non-master page file, you get the following markup:

<script type="text/javascript">
<!--
var Login1_UserNameRequired = document.all ?
document.all["Login1_UserNameRequired"] :
document.getElementById("Login1_UserNameRequired") ;
Login1_UserNameRequired.controltovalidate = "Login1_UserName";
Login1_UserNameRequired.errormessage = "User Name is required.";
Login1_UserNameRequired.validationGroup = "Login1";
Login1_UserNameRequired.evaluationfunction =
"RequiredFieldValidatorEvaluateIsValid";
Login1_UserNameRequired.initialvalue = "";
var Login1_PasswordRequired = document.all ?
document.all["Login1_PasswordRequired"] :
document.getElementById("Login1_PasswordRequired") ;
Login1_PasswordRequired.controltovalidate = "Login1_Password";
Login1_PasswordRequired.errormessage = "Password is required.";
Login1_PasswordRequired.validationGroup = "Login1";
Login1_PasswordRequired.evaluationfunction =
"RequiredFieldValidatorEvaluateIsValid";
Login1_PasswordRequired.initialvalue = "";
var ValidationSummary1 = document.all ?
document.all["ValidationSummary1"] :
document.getElementById("ValidationSummary1");
ValidationSummary1.validationGroup = "Login1";
// -->
</script>

However, when I use the master page code, you get:

<script type="text/javascript">
<!--
var ctl00_ContentPlaceHolder1_Login1_UserNameRequired = document.all ?
document.all["ctl00_ContentPlaceHolder1_Login1_UserNameRequired "] :
document.getElementById("ctl00_ContentPlaceHolder1 _Login1_UserNameRequired");
ctl00_ContentPlaceHolder1_Login1_UserNameRequired. controltovalidate =
"ctl00_ContentPlaceHolder1_Login1_UserName";
ctl00_ContentPlaceHolder1_Login1_UserNameRequired. errormessage = "User
Name is required.";
ctl00_ContentPlaceHolder1_Login1_UserNameRequired. validationGroup =
"ctl00$ContentPlaceHolder1$Login1";
ctl00_ContentPlaceHolder1_Login1_UserNameRequired. evaluationfunction =
"RequiredFieldValidatorEvaluateIsValid";
ctl00_ContentPlaceHolder1_Login1_UserNameRequired. initialvalue = "";
var ctl00_ContentPlaceHolder1_Login1_PasswordRequired = document.all ?
document.all["ctl00_ContentPlaceHolder1_Login1_PasswordRequired "] :
document.getElementById("ctl00_ContentPlaceHolder1 _Login1_PasswordRequired");
ctl00_ContentPlaceHolder1_Login1_PasswordRequired. controltovalidate =
"ctl00_ContentPlaceHolder1_Login1_Password";
ctl00_ContentPlaceHolder1_Login1_PasswordRequired. errormessage =
"Password is required.";
ctl00_ContentPlaceHolder1_Login1_PasswordRequired. validationGroup =
"ctl00$ContentPlaceHolder1$Login1";
ctl00_ContentPlaceHolder1_Login1_PasswordRequired. evaluationfunction =
"RequiredFieldValidatorEvaluateIsValid";
ctl00_ContentPlaceHolder1_Login1_PasswordRequired. initialvalue = "";
var ctl00_ContentPlaceHolder1_ValidationSummary1 = document.all ?
document.all["ctl00_ContentPlaceHolder1_ValidationSummary1"] :
document.getElementById("ctl00_ContentPlaceHolder1 _ValidationSummary1");
ctl00_ContentPlaceHolder1_ValidationSummary1.valid ationGroup =
"ContentPlaceHolder1.Login1";
// -->
</script>

It seems that the ValidationGroup for the internal controls of the
Login control has been changed from "Login1" to
"ctl00$ContentPlaceHolder1$Login1" causing a mis-match between the
Login control and ValidationSummary.

Is there a way of rectifying this?

Many thanks in hope of a reply!!

Ian

Mar 1 '06 #2
DWS

Thanks for taking the time to reply.

Whilst the Login control does have it's own validation - it only
displays the asterisk after the textbox and does not actually display a
message. This could be missed by some users.

I was hoping that the validation summary would show the error in a more
explicit way. I don't feel I am doing anything wrong - the
combination of Login and ValidationSummary works fine when not used
within a Content Placeholder.

I have so far worked around it by using the FindControl method:

Dim myLogin As Login
Dim mySummary As ValidationSummary
myLogin =
[LoginViewControlName].FindControl("[LoginControlName]")
mySummary =
[LoginViewControlName].FindControl("[ValidationSummaryControlName")
If myLogin IsNot Nothing Then
' Replace the returned underscores with dollar signs.
mySummary.ValidationGroup = Replace(myLogin.ClientID, "_",
"$")
End If

However, I'm really not happy in having to do it this way, and so any
other suggestions are more than welcome.

Many thanks
Ian

Mar 1 '06 #3
Ian,

I was having the same problem last night. It frustrated me for a good two
hours and I still have no fix. Glad to see that it's a problem with the
Master Pages, that was what I was going to try to test this time around... I
will probably end up using your workaround for now. If I come up with
something else I will let you know.

Dan

"ilockett" wrote:
DWS

Thanks for taking the time to reply.

Whilst the Login control does have it's own validation - it only
displays the asterisk after the textbox and does not actually display a
message. This could be missed by some users.

I was hoping that the validation summary would show the error in a more
explicit way. I don't feel I am doing anything wrong - the
combination of Login and ValidationSummary works fine when not used
within a Content Placeholder.

I have so far worked around it by using the FindControl method:

Dim myLogin As Login
Dim mySummary As ValidationSummary
myLogin =
[LoginViewControlName].FindControl("[LoginControlName]")
mySummary =
[LoginViewControlName].FindControl("[ValidationSummaryControlName")
If myLogin IsNot Nothing Then
' Replace the returned underscores with dollar signs.
mySummary.ValidationGroup = Replace(myLogin.ClientID, "_",
"$")
End If

However, I'm really not happy in having to do it this way, and so any
other suggestions are more than welcome.

Many thanks
Ian

Apr 20 '06 #4

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

Similar topics

4
by: patrick_a | last post by:
Hello, I am trying to insert multiple instances of a custom user control into a placeholder on an aspx page, based on the records retrieved from the database. I use the datareader to loop through...
2
by: paul meaney | last post by:
All, myself and another developer have been staring blankly at a screen for the past 48 hours and are wondering just what stunningly obvious thing we are missing. We are trying to load up 2...
7
by: A.M | last post by:
Hi, I have a validation control in my page that upon any invalid data, it disables all buttons in the page. basicly i don't have any postback in the page if the validator finds any error. How...
0
by: RSB | last post by:
Hi Every one, i am trying to create a UserControl and i am passing a Array of strings to it. Now based on the Array elements i am creating the LinkButtons Dynamically. I am also passing a Event to...
2
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...
2
by: Vivek Sharma | last post by:
Hi There, I have a situation where I wish to load the controls dynamically on the basis of user role. Hence, I am using this code. if (UserRole == "IS Administrator") { Control UC1 =...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
0
by: apenly | last post by:
Hi all- I'm trying to Render a TreeView in a custom control, but I'm receiving a NullReferenceException at runtime. If I put the TreeView on the page it works fine, but as soon as I try to...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
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...
1
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...
1
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.