473,597 Members | 2,749 Online
Bytes | Software Development & Data Engineering Community
+ 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
ValidationSumma ry control.

I have set the ValidationSumma ry'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 ValidationSumma ry 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_UserName Required = document.all ?
document.all["Login1_UserNam eRequired"] :
document.getEle mentById("Login 1_UserNameRequi red");
Login1_UserName Required.contro ltovalidate = "Login1_UserNam e";
Login1_UserName Required.errorm essage = "User Name is required.";
Login1_UserName Required.valida tionGroup = "Login1";
Login1_UserName Required.evalua tionfunction =
"RequiredFieldV alidatorEvaluat eIsValid";
Login1_UserName Required.initia lvalue = "";
var Login1_Password Required = document.all ?
document.all["Login1_Passwor dRequired"] :
document.getEle mentById("Login 1_PasswordRequi red");
Login1_Password Required.contro ltovalidate = "Login1_Passwor d";
Login1_Password Required.errorm essage = "Password is required.";
Login1_Password Required.valida tionGroup = "Login1";
Login1_Password Required.evalua tionfunction =
"RequiredFieldV alidatorEvaluat eIsValid";
Login1_Password Required.initia lvalue = "";
var ValidationSumma ry1 = document.all ?
document.all["ValidationSumm ary1"] :
document.getEle mentById("Valid ationSummary1") ;
ValidationSumma ry1.validationG roup = "Login1";
// -->
</script>

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

<script type="text/javascript">
<!--
var ctl00_ContentPl aceHolder1_Logi n1_UserNameRequ ired = document.all ?
document.all["ctl00_ContentP laceHolder1_Log in1_UserNameReq uired"] :
document.getEle mentById("ctl00 _ContentPlaceHo lder1_Login1_Us erNameRequired" );
ctl00_ContentPl aceHolder1_Logi n1_UserNameRequ ired.controltov alidate =
"ctl00_ContentP laceHolder1_Log in1_UserName";
ctl00_ContentPl aceHolder1_Logi n1_UserNameRequ ired.errormessa ge = "User
Name is required.";
ctl00_ContentPl aceHolder1_Logi n1_UserNameRequ ired.validation Group =
"ctl00$ContentP laceHolder1$Log in1";
ctl00_ContentPl aceHolder1_Logi n1_UserNameRequ ired.evaluation function =
"RequiredFieldV alidatorEvaluat eIsValid";
ctl00_ContentPl aceHolder1_Logi n1_UserNameRequ ired.initialval ue = "";
var ctl00_ContentPl aceHolder1_Logi n1_PasswordRequ ired = document.all ?
document.all["ctl00_ContentP laceHolder1_Log in1_PasswordReq uired"] :
document.getEle mentById("ctl00 _ContentPlaceHo lder1_Login1_Pa sswordRequired" );
ctl00_ContentPl aceHolder1_Logi n1_PasswordRequ ired.controltov alidate =
"ctl00_ContentP laceHolder1_Log in1_Password";
ctl00_ContentPl aceHolder1_Logi n1_PasswordRequ ired.errormessa ge =
"Password is required.";
ctl00_ContentPl aceHolder1_Logi n1_PasswordRequ ired.validation Group =
"ctl00$ContentP laceHolder1$Log in1";
ctl00_ContentPl aceHolder1_Logi n1_PasswordRequ ired.evaluation function =
"RequiredFieldV alidatorEvaluat eIsValid";
ctl00_ContentPl aceHolder1_Logi n1_PasswordRequ ired.initialval ue = "";
var ctl00_ContentPl aceHolder1_Vali dationSummary1 = document.all ?
document.all["ctl00_ContentP laceHolder1_Val idationSummary1 "] :
document.getEle mentById("ctl00 _ContentPlaceHo lder1_Validatio nSummary1");
ctl00_ContentPl aceHolder1_Vali dationSummary1. validationGroup =
"ContentPlaceHo lder1.Login1";
// -->
</script>

It seems that the ValidationGroup for the internal controls of the
Login control has been changed from "Login1" to
"ctl00$ContentP laceHolder1$Log in1" causing a mis-match between the
Login control and ValidationSumma ry.

Is there a way of rectifying this?

Many thanks in hope of a reply!!

Ian

Feb 27 '06 #1
3 5777
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
ValidationSumma ry control.

I have set the ValidationSumma ry'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 ValidationSumma ry 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_UserName Required = document.all ?
document.all["Login1_UserNam eRequired"] :
document.getEle mentById("Login 1_UserNameRequi red");
Login1_UserName Required.contro ltovalidate = "Login1_UserNam e";
Login1_UserName Required.errorm essage = "User Name is required.";
Login1_UserName Required.valida tionGroup = "Login1";
Login1_UserName Required.evalua tionfunction =
"RequiredFieldV alidatorEvaluat eIsValid";
Login1_UserName Required.initia lvalue = "";
var Login1_Password Required = document.all ?
document.all["Login1_Passwor dRequired"] :
document.getEle mentById("Login 1_PasswordRequi red");
Login1_Password Required.contro ltovalidate = "Login1_Passwor d";
Login1_Password Required.errorm essage = "Password is required.";
Login1_Password Required.valida tionGroup = "Login1";
Login1_Password Required.evalua tionfunction =
"RequiredFieldV alidatorEvaluat eIsValid";
Login1_Password Required.initia lvalue = "";
var ValidationSumma ry1 = document.all ?
document.all["ValidationSumm ary1"] :
document.getEle mentById("Valid ationSummary1") ;
ValidationSumma ry1.validationG roup = "Login1";
// -->
</script>

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

<script type="text/javascript">
<!--
var ctl00_ContentPl aceHolder1_Logi n1_UserNameRequ ired = document.all ?
document.all["ctl00_ContentP laceHolder1_Log in1_UserNameReq uired"] :
document.getEle mentById("ctl00 _ContentPlaceHo lder1_Login1_Us erNameRequired" );
ctl00_ContentPl aceHolder1_Logi n1_UserNameRequ ired.controltov alidate =
"ctl00_ContentP laceHolder1_Log in1_UserName";
ctl00_ContentPl aceHolder1_Logi n1_UserNameRequ ired.errormessa ge = "User
Name is required.";
ctl00_ContentPl aceHolder1_Logi n1_UserNameRequ ired.validation Group =
"ctl00$ContentP laceHolder1$Log in1";
ctl00_ContentPl aceHolder1_Logi n1_UserNameRequ ired.evaluation function =
"RequiredFieldV alidatorEvaluat eIsValid";
ctl00_ContentPl aceHolder1_Logi n1_UserNameRequ ired.initialval ue = "";
var ctl00_ContentPl aceHolder1_Logi n1_PasswordRequ ired = document.all ?
document.all["ctl00_ContentP laceHolder1_Log in1_PasswordReq uired"] :
document.getEle mentById("ctl00 _ContentPlaceHo lder1_Login1_Pa sswordRequired" );
ctl00_ContentPl aceHolder1_Logi n1_PasswordRequ ired.controltov alidate =
"ctl00_ContentP laceHolder1_Log in1_Password";
ctl00_ContentPl aceHolder1_Logi n1_PasswordRequ ired.errormessa ge =
"Password is required.";
ctl00_ContentPl aceHolder1_Logi n1_PasswordRequ ired.validation Group =
"ctl00$ContentP laceHolder1$Log in1";
ctl00_ContentPl aceHolder1_Logi n1_PasswordRequ ired.evaluation function =
"RequiredFieldV alidatorEvaluat eIsValid";
ctl00_ContentPl aceHolder1_Logi n1_PasswordRequ ired.initialval ue = "";
var ctl00_ContentPl aceHolder1_Vali dationSummary1 = document.all ?
document.all["ctl00_ContentP laceHolder1_Val idationSummary1 "] :
document.getEle mentById("ctl00 _ContentPlaceHo lder1_Validatio nSummary1");
ctl00_ContentPl aceHolder1_Vali dationSummary1. validationGroup =
"ContentPlaceHo lder1.Login1";
// -->
</script>

It seems that the ValidationGroup for the internal controls of the
Login control has been changed from "Login1" to
"ctl00$ContentP laceHolder1$Log in1" causing a mis-match between the
Login control and ValidationSumma ry.

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 ValidationSumma ry 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 ValidationSumma ry
myLogin =
[LoginViewContro lName].FindControl("[LoginControlNam e]")
mySummary =
[LoginViewContro lName].FindControl("[ValidationSumma ryControlName")
If myLogin IsNot Nothing Then
' Replace the returned underscores with dollar signs.
mySummary.Valid ationGroup = 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 ValidationSumma ry 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 ValidationSumma ry
myLogin =
[LoginViewContro lName].FindControl("[LoginControlNam e]")
mySummary =
[LoginViewContro lName].FindControl("[ValidationSumma ryControlName")
If myLogin IsNot Nothing Then
' Replace the returned underscores with dollar signs.
mySummary.Valid ationGroup = 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
8789
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 the records and I want to create a new instance of the user control for each record and then change the properties of the controls within each user control. The problem is that after I create the new instance of the user control, I get a...
2
3016
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 or more user controls dynamically by adding to a placeholder defined in page_load. I've included the sample code for how we are accessing one. The user controls are not rocket science - just a few text boxes with public accessor properties. We've...
7
2864
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 can have the validator just disable certain control's postback and other part of page continue their functionality. Thanks,
0
1656
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 this control and Lining the OnClick event of these LinkButtons to this Event. (Which works fine). Now the Thing which i cannot achieve is i want to Change the Back Color of the Clicked to LinkButton To a different color and i also don't want to...
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 get the custom validation message to show up if invalid. So far I have the summary control...
2
1701
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 = LoadControl("../UserControls/ISJob/uctlJobGeneral.ascx");
8
3010
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 way I'm going about doing this might be a little off. I'd appreciate some help. Below is the code I have thus far but I'm not sure how to reference the user control within the foreach loop. <asp:Panel ID="pnlRosterProfile" runat="Server" />
0
2471
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 render it within my control it crashes and burns. I've even tried placing it within another control (a PlaceHolder) and tried to render the PlaceHolder to no avail. Any ideas on how to fix this problem? Here's my code:
2
15061
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 been able to find the cause of the problem, and will describe it here first textually and then through a code example. The purpose of what I am trying to do is to create a postback-free web application through the use of ASP.net AJAX UpdatePanels...
0
7886
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8381
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8035
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8258
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5431
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3927
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2404
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
1
1494
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1238
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.