Hi Andrew,
According to your description, I've performed some tests, it seems a simple
page with dropdownlist and requiredFieldValidator will not produce the
exact behavior. Here is a simple test page I used:
========aspx============
<form id="form1" runat="server">
<div>
</div>
<asp
ropDownList ID="DropDownList1" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem>aaa</asp:ListItem>
<asp:ListItem>bbb</asp:ListItem>
<asp:ListItem>ccc</asp:ListItem>
</asp
ropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="DropDownList1"
ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
<br />
<br />
<asp
ropDownList ID="DropDownList2" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem>aaa</asp:ListItem>
<asp:ListItem>bbb</asp:ListItem>
<asp:ListItem>ccc</asp:ListItem>
</asp
ropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="DropDownList2"
ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
<br />
<br />
<asp
ropDownList ID="DropDownList3" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem>aaa</asp:ListItem>
<asp:ListItem>bbb</asp:ListItem>
<asp:ListItem>ccc</asp:ListItem>
</asp
ropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="DropDownList3"
ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
<br />
<br />
<asp:Button ID="btnPost" runat="server" onclick="btnPost_Click"
Text="Post Button" />
<asp:Button ID="btnClear" runat="server" onclick="btnClear_Click"
Text="Clear Button" />
</form>
=-========code behind=======
public partial class ValidatePage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnPost_Click(object sender, EventArgs e)
{
}
protected void btnClear_Click(object sender, EventArgs e)
{
Response.Write("<br/>Page.IsValid: " + Page.Validators[0].IsValid);
DropDownList1.ClearSelection();
DropDownList2.ClearSelection();
DropDownList3.ClearSelection();
Response.Write("<br/>Page.IsValid: " + Page.Validators[0].IsValid);
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
Response.Write("<br/>Page.IsValid: " + Page.Validators[0].IsValid);
}
}
=======================
It seems as long as the page postback(when I click the Clear Button) and
passed client-side validation, the server-side validation won't return
false after I "ClearSelection" on the dropdownlists.
As you mentioned that there are other forms and usercontrols, I'm wondering
whether some input entry in them may cause the problem. Have you tried
removing some of them to isolate the behavior?
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
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/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------