Hi,
I am using RadDatePicker control to accept date of birth. The scenario is as follows:
My RadDatePicker control is in the dotnet datagrid (so each row will have its own instance of RadDatePicker).
There is another column in my datagrid named 'Age' which consists of normal textbox control. As per my business logic, I need to disable DateOfBirth if the age is entered and vice versa. I was trying to call javascript onblur of both the conrtols but couldn't do.
Below is my javascript code:
function disableAgeOrDOB(birthDate, age)
{
if(birthDate.GetDate() != null && birthDate.GetDate()!= "")
{
age.disabled = true;
}
else if(age.value != null && age.value != "")
{
birthDate.DateInput.Enable() = false;
}
}
and here is markup:
<asp:DataGrid ID="dgTraveler" runat="server" AutoGenerateColumns="False" Width="100%"
HeaderStyle-CssClass="basic_textBold bg_lightorange" ItemStyle-HorizontalAlign="Center"
GridLines="Both" HeaderStyle-HorizontalAlign="Center">
<Columns>
<asp:TemplateColumn HeaderText="Date Of Birth (ddmmmyyyy)" HeaderStyle-Width="200px"
HeaderStyle-HorizontalAlign="Right">
<ItemTemplate>
<telerik:RadDatePicker ID="dtBirthDatePicker" runat="server" MinDate="01-01-1900">
<DateInput DisplayDateFormat="dd-MMM-yyyy">
</DateInput>
</telerik:RadDatePicker>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Age" HeaderStyle-Width="60px">
<ItemTemplate>
<asp:TextBox runat="server" ID="txtAge" MaxLength="3" Width="50px" onkeypress="return AllowNumbersOnly();" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
Here is what I tried in ItemDataBound of datagrid in code behind:
RadDatePicker birthDate = (RadDatePicker)e.Item.FindControl( "dtBirthDatePicker" );
birthDate.DateInput.ClientEvents.OnBlur = string.Format( "disableAgeOrDOB('{0}','{1})'", birthDate.ClientID, age.ClientID);
I have also tried,
birthDate.DateInput.Attributes.Add("onblur", string.Format("disableAgeOrDOB('{0}','{1}');", birthDate.ID, age.ClientID));
I tried many other options also but couldn't succeed. I searched for posts but still didn't get any solution.
Can you please suggest any solution for it?
I am using RadDatePicker control to accept date of birth. The scenario is as follows:
My RadDatePicker control is in the dotnet datagrid (so each row will have its own instance of RadDatePicker).
There is another column in my datagrid named 'Age' which consists of normal textbox control. As per my business logic, I need to disable DateOfBirth if the age is entered and vice versa. I was trying to call javascript onblur of both the conrtols but couldn't do.
Below is my javascript code:
function disableAgeOrDOB(birthDate, age)
{
if(birthDate.GetDate() != null && birthDate.GetDate()!= "")
{
age.disabled = true;
}
else if(age.value != null && age.value != "")
{
birthDate.DateInput.Enable() = false;
}
}
and here is markup:
<asp:DataGrid ID="dgTraveler" runat="server" AutoGenerateColumns="False" Width="100%"
HeaderStyle-CssClass="basic_textBold bg_lightorange" ItemStyle-HorizontalAlign="Center"
GridLines="Both" HeaderStyle-HorizontalAlign="Center">
<Columns>
<asp:TemplateColumn HeaderText="Date Of Birth (ddmmmyyyy)" HeaderStyle-Width="200px"
HeaderStyle-HorizontalAlign="Right">
<ItemTemplate>
<telerik:RadDatePicker ID="dtBirthDatePicker" runat="server" MinDate="01-01-1900">
<DateInput DisplayDateFormat="dd-MMM-yyyy">
</DateInput>
</telerik:RadDatePicker>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Age" HeaderStyle-Width="60px">
<ItemTemplate>
<asp:TextBox runat="server" ID="txtAge" MaxLength="3" Width="50px" onkeypress="return AllowNumbersOnly();" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
Here is what I tried in ItemDataBound of datagrid in code behind:
RadDatePicker birthDate = (RadDatePicker)e.Item.FindControl( "dtBirthDatePicker" );
birthDate.DateInput.ClientEvents.OnBlur = string.Format( "disableAgeOrDOB('{0}','{1})'", birthDate.ClientID, age.ClientID);
I have also tried,
birthDate.DateInput.Attributes.Add("onblur", string.Format("disableAgeOrDOB('{0}','{1}');", birthDate.ID, age.ClientID));
I tried many other options also but couldn't succeed. I searched for posts but still didn't get any solution.
Can you please suggest any solution for it?