This is a migrated thread and some comments may be shown as answers.

telerik:RadDatePicker Change how to fire java script

2 Answers 182 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mohamed
Top achievements
Rank 1
mohamed asked on 11 Oct 2011, 08:32 AM
Hello every one ,

My problem how to fire the javascript in raddatepicker changed

aspx
<telerik:RadDatePicker ID="DateofCommencement" AutoCompleteType="Disabled" runat="server"
DbSelectedDate='<%# Bind("DtCommencement") %>' >
<DateInput ID="DateInput1" DateFormat="dd/MM/yyyy" runat="server" ReadOnly="true" >
</DateInput>                                                           
</telerik:RadDatePicker>

.cs

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            {
                RadDatePicker StartDate = (RadDatePicker)e.Item.FindControl("DateofCommencement");
                RadNumericTextBox Duration = (RadNumericTextBox)e.Item.FindControl("Duration");
                RadDatePicker EndDate = (RadDatePicker)e.Item.FindControl("DateofCompletion");
                StartDate.Attributes.Add("onclick", string.Format("changeEndDate('{0}','{1}','{2}');", StartDate.ClientID, Duration.ClientID, EndDate.ClientID));
                Duration.Attributes.Add("onblur", string.Format("changeEndDate('{0}','{1}','{2}');", StartDate.ClientID, Duration.ClientID, EndDate.ClientID));
            }
        }

Thanks,
Mohamed.

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 11 Oct 2011, 08:55 AM
Hello Mohammed,

The RadControls expects only two parameters as its arguments, sender and arguments. You cannot pass the extra arguments directly.
The easiest way to pass predefined parameters to a function executed on the clientside, is to assign anonymous function and pass the parameters:
Here is a sample code.
C#:
string a = "value1", b = "value2";
options.ClientEvents.OnDateSelected ="function (button,args){OptionSelected('"+ a +"','"+ b +"');}";
JS:
<script type="text/javascript">
function OptionSelected(text, title)
{
  alert(text + " " + title);
}
</script>

Thanks,
Princy.
0
mohamed
Top achievements
Rank 1
answered on 13 Oct 2011, 12:01 PM

Thanks for your reply Princy

StartDate.ClientEvents.OnDateSelected = "function (button,button1,args){changeEndDate('" + StartDate.ClientID + "','" + Duration.ClientID + "','" + EndDate.ClientID + "');}";


Thanks,
Mohamed.
Tags
Grid
Asked by
mohamed
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
mohamed
Top achievements
Rank 1
Share this question
or