|
Rank: Advanced Member Groups: Member
Joined: 5/30/2007 Posts: 42
|
Hello, I'm trying to add a Clientside is dirty on the datepicker after the date is changed, I need to set a Clientside var and change the background color of the textbox in the datepicker. How do i set the background color on clientside using JavaScipt when the date is changed/slected?
Patrick Beverloo OfficeSpecialisten www.OfficeSpecialisten.nl
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi Patrick,
The calendar itself won't do that for you. But I imagine you can do it with some minimum JavaScript trick. First you will need to find out the ID of the textbox control. The ID is not the same as the date picker's ID. You should be able to find that out by view page source. Once you have that you can just use JavaScript to change the style property to change the background color.
Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 5/30/2007 Posts: 42
|
How can i get the id from ClientSideOnSelect event
Code: HTML/ASPX
<eo:DatePicker ID="txtEmployedUntil" runat="server" DayCellHeight="16" DayCellWidth="19"
DayHeaderFormat="FirstLetter" DisabledDates="" OtherMonthDayVisible="True" PickerFormat="dd-MM-yyyy"
SelectedDates="" TitleLeftArrowImageUrl="DefaultSubMenuIconRTL" TitleRightArrowImageUrl="DefaultSubMenuIcon"
PopupExpandDirection="Bottom" "txtEmployedUntil" runat="server" DayCellHeight="16" DayCellWidth="19"
DayHeaderFormat="FirstLetter" DisabledDates="" OtherMonthDayVisible="True" PickerFormat="dd-MM-yyyy"
SelectedDates="" TitleLeftArrowImageUrl="DefaultSubMenuIconRTL" TitleRightArrowImageUrl="DefaultSubMenuIcon"
PopupExpandDirection="Bottom" ClientSideOnSelect="testevent" >
</eo:DatePicker>="testevent" >
</eo:DatePicker>
Code: JavaScript
function testevent(calendar, eventName){
if (eventName == 'Select'){
alert(calendar);
alert(calendar.ID);
}
}
Patrick Beverloo OfficeSpecialisten www.OfficeSpecialisten.nl
|
|
Rank: Advanced Member Groups: Member
Joined: 5/30/2007 Posts: 42
|
I have the code to change the color
Code: C#
if (!ClientScript.IsClientScriptBlockRegistered("DatePicker-onchange-function"))
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "DatePicker-onchange-function", "<script language='JavaScript'>" +
"function DatePicker_checkForChange(obj) {\n" +
" var DPControl = document.getElementById('_eo_' + obj + '_picker'); \n" +
" alert(DPControl);\n" +
" isDirty = true;\n" +
" DPControl.style.backgroundColor='#6DC2FF';\n" +
" \n" +
"}\n" +
"</script>");
}
Patrick Beverloo OfficeSpecialisten www.OfficeSpecialisten.nl
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi,
You should use:
alert(calendar.getId());
Please check the help file for all the details.
Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Patrick Beverloo wrote:I have the code to change the color
Code: C#
if (!ClientScript.IsClientScriptBlockRegistered("DatePicker-onchange-function"))
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "DatePicker-onchange-function", "<script language='JavaScript'>" +
"function DatePicker_checkForChange(obj) {\n" +
" var DPControl = document.getElementById('_eo_' + obj + '_picker'); \n" +
" alert(DPControl);\n" +
" isDirty = true;\n" +
" DPControl.style.backgroundColor='#6DC2FF';\n" +
" \n" +
"}\n" +
"</script>");
}
Cool! Thanks for sharing!
|
|
Rank: Advanced Member Groups: Member
Joined: 5/30/2007 Posts: 42
|
The code to change the background color,
Code: C#
if (!ClientScript.IsClientScriptBlockRegistered("DatePicker-onchange-function"))
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "DatePicker-onchange-function", "<script language='JavaScript'>" +
"function DatePicker_checkForChange(calendar, eventName) {\n" +
" if (eventName == 'Select'){\n" +
" var objID = calendar.getId();\n" +
" \n" +
" var DPControl = document.getElementById('_eo_' + objID + '_picker'); \n" +
" isDirty = true;\n" +
" DPControl.style.backgroundColor='#6DC2FF';\n" +
" }\n" +
"}\n" +
"</script>");
}
EO.Web.DatePicker obj = c as EO.Web.DatePicker;
obj.ClientSideOnSelect = "DatePicker_checkForChange";
Patrick Beverloo OfficeSpecialisten www.OfficeSpecialisten.nl
|
|