Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > CustomValidator is hidden

Reply
Thread Tools

CustomValidator is hidden

 
 
David Thielen
Guest
Posts: n/a
 
      05-15-2006
Hi;

I have a CustomValidator that is always drawn hidden. I have tried setting
Visible to true in the aspx and aspx.cs files - and it is still hidden. Any
ideas?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

 
Reply With Quote
 
 
 
 
David Thielen
Guest
Posts: n/a
 
      05-15-2006
ps - this is inside a Repeater/ItemTemplate

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com



"David Thielen" wrote:

> Hi;
>
> I have a CustomValidator that is always drawn hidden. I have tried setting
> Visible to true in the aspx and aspx.cs files - and it is still hidden. Any
> ideas?
>
> --
> thanks - dave
> david_at_windward_dot_net
> http://www.windwardreports.com
>

 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      05-16-2006
Hi Dave,

Thank you for posting.

As for the Custom Validator displaying issue, I think it is mostly a page
specific issue. What's the detailed code/aspx template of that repeater
page? As for custom validator, it will display only when there is
validation error get triggered. Also, are you using client-side validation
or server-side validation?

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


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



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



 
Reply With Quote
 
David Thielen
Guest
Posts: n/a
 
      05-25-2006
Here you go - all server side:

aspx code:
<asp:Repeater ID="mapRows" runat="server" OnDataBinding="MapBinding"
OnItemDataBound="MapDataBound">
<HeaderTemplate>
<tr>
<th colspan='3'>
Report parameters</th>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label ID="mapName" runat="server"
Text='<%#Eval("Name")%>'></asp:Label>
</td>
<td>
<asp:TextBox ID="mapTextValue" runat="server"
Columns="60"></asp:TextBox>
<asp:CustomValidator ID="mapValidator" runat="server"
ErrorMessage="CustomValidator"
ControlToValidate="mapTextValue">yyy</asp:CustomValidator>
<asp:Calendar ID="mapCalendarValue" runat="server"
Visible="false"></asp:Calendar>
<aspropDownList ID="mapListValue" runat="server"
Visible="false"></aspropDownList>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>


cs code:
string key = ((Label)ri.FindControl("mapName")).Text;
CustomValidator validator = (CustomValidator)ri.FindControl("mapValidator");
validator.Text = "Please enter a value for the map var " + key;
validator.IsValid = false;

It sets the text but the field is hidden.

Any ideas?

thanks - dave

 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      05-26-2006
Hi Dave,

Thanks for your response.

From the code snippet you provided, you define the customvalidator with the
following control template:

=================
<asp:CustomValidator ID="mapValidator" runat="server"
ErrorMessage="CustomValidator"
ControlToValidate="mapTextValue">yyy</asp:CustomValidator>
================

I think the problem here is that you didn't provide a Server-side
validation handler(or client-side validate function) for the custom valiate
control. Also, the error message of Validator control will only display
when the validation occurs(and there is validation error). BTW, custom
validation won't occur when the validating control's Field(such as Text
property is empty).

As for how to write a servervalidation handler, you can reference to the
following msdn document:

#ServerValidateEventHandler Delegate
http://msdn.microsoft.com/library/en...webuiwebcontro
lsservervalidateeventhandlerclasstopic.asp?frame=t rue

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


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



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)




 
Reply With Quote
 
David Thielen
Guest
Posts: n/a
 
      05-27-2006
Hi;

Ok, I have it working that way but a couple of things don't make sense.

1) When I click on a button, first it calls the server validation method,
then it calls the button click handler even though the validation method
returned false, then it calls the validation method a second time. So I have
to validate in the button click handler too which makes no sense.

2) I do not have to have an OnServerValidate for any of my other
CustomValidators - just for the one I have inside the Repeater control.

3) It has the validator in the html creates - it's just that it is marked
hidden.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com



"Steven Cheng[MSFT]" wrote:

> Hi Dave,
>
> Thanks for your response.
>
> From the code snippet you provided, you define the customvalidator with the
> following control template:
>
> =================
> <asp:CustomValidator ID="mapValidator" runat="server"
> ErrorMessage="CustomValidator"
> ControlToValidate="mapTextValue">yyy</asp:CustomValidator>
> ================
>
> I think the problem here is that you didn't provide a Server-side
> validation handler(or client-side validate function) for the custom valiate
> control. Also, the error message of Validator control will only display
> when the validation occurs(and there is validation error). BTW, custom
> validation won't occur when the validating control's Field(such as Text
> property is empty).
>
> As for how to write a servervalidation handler, you can reference to the
> following msdn document:
>
> #ServerValidateEventHandler Delegate
> http://msdn.microsoft.com/library/en...webuiwebcontro
> lsservervalidateeventhandlerclasstopic.asp?frame=t rue
>
> Hope this helps.
>
> Regards,
>
> Steven Cheng
> Microsoft Online Community Support
>
>
> ==================================================
>
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
>
> ==================================================
>
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>
>
>
>

 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      05-29-2006
Hi Dave,

Here is my understanding inline:

1) When I click on a button, first it calls the server validation method,
then it calls the button click handler even though the validation method
returned false, then it calls the validation method a second time. So I
have
to validate in the button click handler too which makes no sense.
================================
As for Validation control, when we use server-side validation, the
Validation function of the validators are called after Page Load event, but
before processing postback events. Thus, we can use the Page.IsValid or
ValidatorControl's "IsValid" property determine whether the validation is
passed and our code logic in postback event should also change depend on
this detection.


2) I do not have to have an OnServerValidate for any of my other
CustomValidators - just for the one I have inside the Repeater control.
===============================
Which one(Row) is the one you want to make the validation control enable
validating? I think you can consider using the "ItemCreated" event of
Repeater control to customize certain control in the repeaterItem. Also,
you can consider using DataList control and put your particular validation
control only in the EditTemplate so that only the current Row being edited
will contains the validator control.


3) It has the validator in the html creates - it's just that it is marked
hidden.
=================================
I'm still not quite clear on this. Why would you configure the validator to
be invislbe?

Here are some msdn reference on using validation controls in ASP.NET 2.0:

#Learning More Validation Controls
http://msdn2.microsoft.com/en-us/library/ms178317.aspx

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


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



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate Hidden field on post back and retrieve value from Hidden Field Rick ASP .Net 3 04-13-2010 05:38 PM
Win 7 folders hidden despite 'show hidden' checked Boppy NZ Computing 10 01-23-2010 02:56 AM
How would I discover the text in a block element hidden by overflow:hidden style being set? SolarCanine Javascript 2 09-20-2005 06:27 PM
CustomValidator limitation? Wayne MJ ASP .Net 0 07-21-2003 01:51 AM
Errormessage in CustomValidator Edmilson ASP .Net 0 07-10-2003 12:56 PM



Advertisments