Collapse | Copy Code
scenario
1)two calendar control[fromdate and todate]...both are disabled at start
2)checkbox
3)save button
--if i click the check box...the disabled calendar control becomes enabled...then we enter from and todate
--then if i save it should update
--<<<<<<<<<what i="" require="">>.
if i dont click the check box[that is both fromdate and todate are disabled and are left blank]. and then save it should save.
if i dont click the check box and when i am trying to save..both the calendar control required field validator message is firing..enter valid value in the fields
----------------------aspx code-----------------------------------------------
<tr>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<td align="left" class="style2" colspan="4">
<asp:CheckBox ID="chkroleid" runat="server" Text="Assign Role For Particular Duration"
OnCheckedChanged="chkroleid_CheckedChanged" Checked="false" AutoPostBack="true" />
</td>
</ContentTemplate>
</asp:UpdatePanel>
</tr>
<tr id="FirstRow" runat="server">
<td class="lavel">
<asp:Label ID="ll_Appointment_Date" runat="server" Text="From Date"></asp:Label>
</td>
<td width="25%">
<uc3:CalendarControl ID="txt_Appointment_From_Date" runat="server" ShowTime="true"
SetEnabled="false"/>
</td>
<td class="label" width="10%">
<asp:Label ID="Label2" runat="server" Text="To Date"></asp:Label>
</td>
<td width="25%">
<uc3:CalendarControl ID="txt_Appointment_To_Date" runat="server" ShowTime="true"
SetEnabled="false" />
</td>
</tr>
--custom button panel is having save button--
<uc1:CustomButtonPanel ID="CustomButtonPanel1" align="right" runat="server" />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="You must enter a valid value in the following field(s):"
ShowMessageBox="True" ShowSummary="False" />
---------------------------------------------------------------------------------------
so how to solve this?
Brij-
I m little confused. Can you help me ?
--in user control.ascx i have this
<asp:RequiredFieldValidator ID="Date_rfv" runat="server" SetFocusOnError="true" ControlToValidate="txtCalendarValue"
Display="Dynamic">
-- in usercontrol.ascx.cs
public void SetDateValidators()
{
if (this.RfvDateErrorMsg.Trim().Length > 0)
{
Date_rfv.ErrorMessage = this.RfvDateErrorMsg.ToString();
}
else
{
Date_rfv.ErrorMessage = System.Configuration.ConfigurationSettings.AppSettings["Date_rfv"];
}
}
--in web config the message is declared [enter valid date]
<add key="Date_rfv" value="Enter required date value.">
--------------------------------------------
so when checkbox is not checked.
then the validation below fires
and the the webconfig key message
--custom button panel is having save button--
<pre lang="xml"><uc1:CustomButtonPanel ID="CustomButtonPanel1" align="right" runat="server" />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="You must enter a valid value in the following field(s):"
ShowMessageBox="True" ShowSummary="False" /></pre>
i get error like below
You must enter a valid value in the following field
Enter required date value
Enter required date value
--after reading your article i tried to do
i am trying to do validation on client side..
<asp:CheckBox ID="chkroleid" runat="server" Text="Assign Role For Particular Duration"
OnCheckedChanged="chkroleid_CheckedChanged" Checked="false" Onclick="clientValidation_Calendarcontrol();" AutoPostBack="true" />
function clientValidation_Calendarcontrol(source, arguments)
{
if (chkroleid.checked)
{
}
else
{
var ValidationSummary1 = document.getElementById('ValidationSummary1');
ValidatorEnable(ValidationSummary1, false);
ValidationSummaryOnSubmit();
}
}
--but this is not working,,,
how to disable the validation summary [You must enter a valid value in the following field]
and the part that is declared in usercontrol which is linked with webconfig[Enter required date value]
--kindly help