Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > CustomValidator points to wrong control

Reply
Thread Tools

CustomValidator points to wrong control

 
 
David Thielen
Guest
Posts: n/a
 
      11-02-2006
There is a lot of code below so I will try to explain first. I have a
Repeater and in the Repeater I have a Panel. In the Panel I have a
CustomValidator that needs to work with the value of a control that is
outside the Panel, but inside the Repeater.

What appears to be happening is that if the Panel is visible, it then calls
the CustomValidator - but for the CustomValidator in a different row - that
is hidden.

Here is my code:
protected void ValidateMapDatasource(object sender, ServerValidateEventArgs
args) {
CustomValidator vldtr = (CustomValidator)sender;
DropDownList lst = (DropDownList)vldtr.Parent.Parent.FindControl("map Type");
if (lst.SelectedIndex != 4) {
args.IsValid = true;
return;
}
// should come to here as SelectedIndex == 4 if the Panel is visible - but
returns above because it gets the lst for the next row.

Here is the aspx:
<asp:Repeater ID="mapRows" runat="server"
OnItemDataBound="MapDataBind">
<HeaderTemplate>
<table width="100%">
<tr>
<th>
<asp:Localize ID="Localize9" runat="server" Text='required'
/></th>
<th>
<asp:Localize ID="Localize10" runat="server" Text='<%$
Resources:Header, VarName %>' /></th>
<th>
<asp:Localize ID="Localize11" runat="server" Text='type' /></th>
<th>
<asp:Localize ID="Localize12" runat="server" Text='description'
/></th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:CheckBox ID="mapRequired" runat="server"
Checked='<%#Eval("Required")%>' /></td>
<td>
<asp:Label ID="mapName" runat="server"
Text='<%#Eval("Name")%>'></asp:Label>
</td>
<td>
<aspropDownList ID="mapType" runat="server"
SelectedIndex='<%#Eval("Type")%>'>
<asp:ListItem Value="0" Text='<%$ Resources:Value, Currency %>' />
<asp:ListItem Value="1" Text='<%$ Resources:Value, Date %>' />
<asp:ListItem Value="2" Text='<%$ Resources:Value, Integer %>' />
<asp:ListItem Value="3" Text='<%$ Resources:Value, Number %>' />
<asp:ListItem Value="4" Text='<%$ Resources:Value, Select %>' />
<asp:ListItem Value="5" Text='<%$ Resources:Value, Text %>' />
</aspropDownList>
</td>
<td>
<asp:TextBox ID="mapDescription" runat="server" Columns="60"
Rows="4" Height="72px"
TextMode="MultiLine" />
<aspWindward:HelpLink ID="HelpLink6" runat="server"
File="template3" Bookmark="mapvalues" />
<aspanel ID="mapSelectPanel" runat="server">
<br />
<asp:Localize ID="Localize13" runat="server" Text='<%$
Resourcesrompt, Select %>' />
<asp:TextBox ID="mapSelect" runat="server" Columns="50"
Text='<%#Eval("Select")%>'></asp:TextBox>
<aspropDownList ID="mapSelectDatasource" runat="server" />
<asp:CustomValidator ID="CustomValidator2" runat="server"
OnServerValidate="ValidateMapDatasource"
ControlToValidate="mapSelectDatasource" Text="Please select a
datasource." />
</aspanel>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>

Any ideas?

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

Cubicle Wars - http://www.windwardreports.com/film.htm


 
Reply With Quote
 
 
 
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      11-03-2006
Hi David,

I have done some test, but wasn't able to reproduce the issue you mentioned.

First, I don't think the FindControl("mapType") is returning the wrong
DropDownList, can you verify that, for example: change the found
DropDownList's SelectedIndex in the validate event.

During my test, if I bound the repeater in every postback, the state of the
DropDownList will be lost and the SelectedIndex will always be 0.

Could you please post the complete webform so that I can test that? Thanks.

Sincerely,
Walter Wang ((E-Mail Removed), remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

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

 
Reply With Quote
 
 
 
 
David Thielen
Guest
Posts: n/a
 
      11-03-2006
I swear this was working wrong yesterday - but it is working fine now. If I
get the problem again I will get as much info as I can from it.

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

Cubicle Wars - http://www.windwardreports.com/film.htm




"Walter Wang [MSFT]" wrote:

> Hi David,
>
> I have done some test, but wasn't able to reproduce the issue you mentioned.
>
> First, I don't think the FindControl("mapType") is returning the wrong
> DropDownList, can you verify that, for example: change the found
> DropDownList's SelectedIndex in the validate event.
>
> During my test, if I bound the repeater in every postback, the state of the
> DropDownList will be lost and the SelectedIndex will always be 0.
>
> Could you please post the complete webform so that I can test that? Thanks.
>
> Sincerely,
> Walter Wang ((E-Mail Removed), remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscripti...ult.aspx#notif
> ications. If you are using Outlook Express, please make sure you clear the
> check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
> promptly.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscripti...t/default.aspx.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>

 
Reply With Quote
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      11-04-2006
Hi David,

Please feel free to let me know if the problem occurrs again.

Have a nice weekend!

Regards,
Walter Wang ((E-Mail Removed), remove 'online.')
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.

 
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
windows question: default click action points to wrong python version Gelonida N Python 1 11-21-2012 09:14 PM
Re: windows question: default click action points to wrong pythonversion Gelonida N Python 0 11-21-2012 07:30 PM
Re: windows question: default click action points to wrong pythonversion Tim Golden Python 0 11-21-2012 09:34 AM
Typed DataSet in DLL points to wrong database! MaxGruven ASP .Net 7 06-09-2008 02:09 AM
CustomValidator Control Jim Heavey ASP .Net 1 12-02-2003 03:55 PM



Advertisments