i create server control with jquery datepicker , which i initial in my render method. in the textbox i set autopostback and add custom event to fire on textchanged this is the server side :
protected override void CreateChildControls()
{
base.CreateChildControls();
_txtCalender = new TextBox();
_txtCalender.ID = "_txtCalender" + this.ID;
_txtCalender.ReadOnly = true;
_txtCalender.AutoPostBack = true;
_txtCalender.TextChanged += new EventHandler(_txtCalender_TextChanged);
Controls.Add(_txtCalender);
}
//Raised when the select Change
public event EventHandler SelectionDateChanged
{
add
{
Events.AddHandler(eventSelectedChange, value);
}
remove
{
Events.RemoveHandler(eventSelectedChange, value);
}
}
private void _OnSelectedChange(object source, EventArgs e)
{
OnSelectedChange(EventArgs.Empty);
}
//The method that raises the select Change event.
protected void OnSelectedChange(EventArgs e)
{
EventHandler selectedChangeHandler = (EventHandler)Events[eventSelectedChange];
if (selectedChangeHandler != null)
selectedChangeHandler(this, e);
}
on the client side of i set the datepicker select property like that:
onSelect: function (dateText, inst) {
try {
window.console && console.log($(hiddenFld).val());
inst.input.val($(hiddenFld).val());
inst.input.trigger('change');
}
catch (err) {
alert(err);
}
}
when i select date it create postback but it not getting in to the OnTextChanged what did i missed?
this is solved. i hope it could help someone ,
when i took this line out:
_txtCalender.ReadOnly = true;
it works and i didnt have to add the trigger onSelect. i just delete those line from my javascript:
onSelect: function (dateText, inst) {
try {
window.console && console.log($(hiddenFld).val());
inst.input.val($(hiddenFld).val());
inst.input.trigger('change');
}
catch (err) {
alert(err);
}
}