Welcome Guest Search | Active Topics | Sign In | Register

datepicker Options
Raghav Nayak
Posted: Thursday, March 12, 2009 10:06:13 AM
Rank: Advanced Member
Groups: Member

Joined: 8/21/2008
Posts: 37
Hi,

I've placed month, year function for my date picker. And I've added the datepicker control in multiple places in the same form. But when i try to select the year or month, nothing will open up. Instead, I'll get the below alert message.

"function eo_Getobject encountered multiple objects with same id. This happens when multiple server controls have the same id, but resides in different naming containers.... please correct the problem by calling eo_getobject with the client id of the control instead of the id of the control....."

Could you please look into this?

Thanks in advance.

Regards,
Raghav

Below is my code:

Code: HTML/ASPX
<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>
<%@ Control AutoEventWireup="true" CodeFile="DatePicker.ascx.cs" Inherits="DatePicker" Language="C#" %>

<script type="text/javascript">

var g_curCalendar = null;

function ShowMonthPopup(refLink)
{
	g_curCalendar = "<%=DatePicker1.ClientID%>";
	var monthPicker = document.getElementById(refLink);
	eo_GetObject(g_curCalendar).showContextMenu(monthPicker, "mnuMonth");
}

function MonthMenuClicked(e, info)
{
	var month = info.getItem().getIndex();
	var calendar = eo_GetObject(g_curCalendar);
	
	//Get the current month
	var curMonth = calendar.getVisibleDate();
	
	//Change the month
	curMonth.setMonth(month);
	
	//Set the new current month
	calendar.goTo(curMonth);
}

function ShowYearPopup(refLink)
{
	g_curCalendar = "<%=DatePicker1.ClientID%>";
	var yearPicker = document.getElementById(refLink);
	eo_GetObject(g_curCalendar).showContextMenu(yearPicker, "mnuYear");
}

function YearMenuClicked(e, info)
{
	var year = info.getItem().getIndex();
	var calendar = eo_GetObject(g_curCalendar);
	
	//Get the current month
	var curMonth = calendar.getVisibleDate();
	
	//Set the new year
	curMonth.setFullYear(year + 1950);
	
	//Set the new current month
	calendar.goTo(curMonth);
}

function ValidateDates(clientID)
{
	//Clear the message first
	var errorDiv = document.getElementById("errordiv");
	errorDiv.innerHTML = "";
	
	//Get the date
	var date = eo_GetObject(clientID).getSelectedDate();	
	
	//Check if date is provided
	if ((date == null))
	{
		errorDiv.innerHTML = "Please select date";
		errordiv.className = "validator_text";
		return false;		
	}	
}

function ValidateWithCurrentDate(sender, args)
{    
    var ctrltova = sender.getAttribute('ControlToValidate');
    var givenDate = eo_GetObject(ctrltova).getSelectedDate();
    
    var operator =  parseInt(sender.getAttribute('operatorID'), 10);
    var currentDateString =  sender.getAttribute('CurrentDate');
    
    var Day = currentDateString.split('/')[0];
    var Month = currentDateString.split('/')[1];
    var Year = currentDateString.split('/')[2]; 
		    		    
	var iDay = eval(Day);
	var iMonth = eval(Month);
	var iYear = eval(Year);	    
    
    var currentDate = new Date(iYear, iMonth - 1, iDay);
   
    switch(operator)
    {
        case 1:
             args.IsValid = givenDate == currentDate;
             break;
        case 2:
             args.IsValid = givenDate != currentDate;
             break;
        case 3:
             args.IsValid = givenDate > currentDate;
             break;
        case 4:
             args.IsValid = givenDate >= currentDate;
             break;
        case 5:
             args.IsValid = givenDate < currentDate;
             break;
        case 6:
             args.IsValid = givenDate <= currentDate;
             break;
    }
}

eo:DatePicker ID="DatePicker1" runat="server" DayCellHeight="15" DayCellWidth="31" DayHeaderFormat="FirstLetter" GridLineColor="207, 217,  227"
    GridLineFrameVisible="False" GridLineVisible="True" PickerFormat="dd/MM/yyyy" TitleFormat="MMM yyyy" TitleLeftArrowImageUrl="DefaultSubMenuIconRTL"
    TitleRightArrowImageUrl="DefaultSubMenuIcon" TitleTemplateScope="TextOnly" Width="100px">
    <TitleTemplate>
        {var:visible_date:MMMM} <a id="month_picker2" href="javascript:ShowMonthPopup('month_picker2')">
            <img border="0" src="{img:00020012}" /></a> {var:visible_date:yyyy} <a id="year_picker2" href="javascript:ShowYearPopup('year_picker2')">
                <img border="0" src="{img:00020012}" /></a>
    </TitleTemplate>
    <SelectedDayStyle CssText="background-color:White;border-bottom-color:Black;bor der-bottom-style:solid;border-bottom-width:1px;border-left-co lor:Black;border-left-style:solid;border-left-width:1px;borde r-right-color:Black;border-right-style:solid;border-right-wid th:1px;border-top-color:Black;border-top-style:solid;border-t op-width:1px;" />
    <DisabledDayStyle CssText="border-bottom-color:#CFD9C0;border-bottom-style:soli d;border-bottom-width:1px;border-left-color:#CFD9C0;border-le ft-style:solid;border-left-width:1px;border-right-color:#CFD9 C0;border-right-style:solid;border-right-width:1px;border-top -color:#CFD9C0;border-top-style:solid;border-top-width:1px;co lor:gray;" />
    <CalendarStyle CssText="border-right: #555566 1px solid;  border-top: #555566 1px solid; border-left: #555566 1px  solid; border-bottom: #555566 1px solid; background-color:  #ebe9ed" />
    <DayHoverStyle CssText="border-right: #bbbbbb 1px solid;  border-top: #bbbbbb 1px solid; border-left: #bbbbbb 1px  solid; border-bottom: #bbbbbb 1px solid; background-color:  #ddeeff" />
    <MonthStyle CssText="font-size: 8pt; cursor: hand;  font-family: verdana; background-color: #cfd9c0" />
    <DayStyle CssText="border-bottom-color:#CFD9C0;border-bottom-style:soli d;border-bottom-width:1px;border-left-color:#CFD9C0;border-le ft-style:solid;border-left-width:1px;border-right-color:#CFD9 C0;border-right-style:solid;border-right-width:1px;border-top -color:#CFD9C0;border-top-style:solid;border-top-width:1px;" />
    <DayHeaderStyle CssText="font-weight: bold; font-size:  11px; color: black; border-bottom: #555566 1px solid;  font-family: verdana; background-color: #ae9c86" />
    <PickerStyle CssText="background-color:pink" />
    <TodayStyle CssText="background-image:url('00040401');color:#1176db;" />
    <DayHeaderStyle CssText="border-bottom: #f5f5f5 1px solid" />
</eo:DatePicker>
<eo:ContextMenu ID="mnuMonth" runat="server" ClientSideOnItemClick="MonthMenuClicked" ControlSkinID="None" Width="80px">
    <TopGroup OffsetX="0" OffsetY="-100" Style-CssText="border-left-color:#e0e0e0;border-left-style:solid;border-left-width:1px;border-right-color:#e0e0e0;border-right-style:solid;border-right-width:1px;border-top-color:#e0e0e0;border-top-style:solid;border-top-width:1px;cursor:hand;font-family:arial;font-size:12px;padding-bottom:3px;padding-left:10px;padding-right:10px;padding-top:3px;">
        <Items>
            <eo:MenuItem Text-Html="January">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="February">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="March">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="April">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="May">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="June">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="July">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="August">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="September">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="October">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="November">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="December">
            </eo:MenuItem>
        </Items>
    </TopGroup>
    <LookItems>
        <eo:MenuItem HoverStyle-CssText="color:#1C7CDC;padding-left:5px;padding-right:5px;" ItemID="_Default" NormalStyle-CssText="color:#2C0B1E;padding-left:5px;padding-right:5px;">
            <SubMenu ItemSpacing="5" ShadowDepth="0" Style-CssText="background-color:White;border-bottom-color:#e0e0e0;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#e0e0e0;border-left-style:solid;border-left-width:1px;border-right-color:#e0e0e0;border-right-style:solid;border-right-width:1px;border-top-color:#e0e0e0;border-top-style:solid;border-top-width:1px;color:#606060;cursor:hand;font-family:arial;font-size:12px;padding-bottom:3px;padding-left:3px;padding-right:3px;padding-top:3px;">
            </SubMenu>
        </eo:MenuItem>
    </LookItems>
</eo:ContextMenu>
<eo:ContextMenu ID="mnuYear" runat="server" ClientSideOnItemClick="YearMenuClicked" ControlSkinID="None" EnableScrolling="True"
    ScrollDownLookID="scroll_down" ScrollUpLookID="scroll_up" Width="80px">
    <TopGroup Height="150" OffsetX="0" OffsetY="-50" Style-CssText="border-left-color:#e0e0e0;border-left-style:solid;border-left-width:1px;border-right-color:#e0e0e0;border-right-style:solid;border-right-width:1px;border-top-color:#e0e0e0;border-top-style:solid;border-top-width:1px;cursor:hand;font-family:arial;font-size:12px;padding-bottom:3px;padding-left:10px;padding-right:10px;padding-top:3px;">
        <Items>
            <eo:MenuItem Text-Html="1950">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1951">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1952">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1953">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1954">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1955">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1956">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1957">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1958">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1959">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1960">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1961">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1962">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1963">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1964">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1965">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1966">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1967">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1968">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1969">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1970">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1971">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1972">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1973">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1974">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1975">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1976">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1977">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1978">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1979">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1980">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1981">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1982">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1983">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1984">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1985">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1986">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1987">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1988">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1989">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1990">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1991">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1992">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1993">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1994">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1995">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1996">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1997">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1998">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="1999">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="2000">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="2001">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="2002">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="2003">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="2004">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="2005">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="2006">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="2007">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="2008">
            </eo:MenuItem>
            <eo:MenuItem Text-Html="2009">
            </eo:MenuItem>
        </Items>
    </TopGroup>
    <LookItems>
        <eo:MenuItem HoverStyle-CssText="color:#1C7CDC;padding-left:5px;padding-right:5px;" ItemID="_Default" NormalStyle-CssText="color:#2C0B1E;padding-left:5px;padding-right:5px;">
            <SubMenu ItemSpacing="5" ShadowDepth="0" Style-CssText="background-color:White;border-bottom-color:#e0e0e0;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#e0e0e0;border-left-style:solid;border-left-width:1px;border-right-color:#e0e0e0;border-right-style:solid;border-right-width:1px;border-top-color:#e0e0e0;border-top-style:solid;border-top-width:1px;color:#606060;cursor:hand;font-family:arial;font-size:12px;padding-bottom:3px;padding-left:3px;padding-right:3px;padding-top:3px;">
            </SubMenu>
        </eo:MenuItem>
        <eo:MenuItem Height="14" Image-Url="00020001" ItemID="scroll_down" NormalStyle-CssText="background-image:url('00020005');border-bottom-color:#E0E0E0;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#E0E0E0;border-left-style:solid;border-left-width:1px;border-right-color:#E0E0E0;border-right-style:solid;border-right-width:1px;border-top-color:#E0E0E0;border-top-style:solid;border-top-width:1px;">
        </eo:MenuItem>
        <eo:MenuItem Height="14" Image-Url="00020000" ItemID="scroll_up" NormalStyle-CssText="background-image:url('00020005');border-bottom-color:#E0E0E0;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#E0E0E0;border-left-style:solid;border-left-width:1px;border-right-color:#E0E0E0;border-right-style:solid;border-right-width:1px;border-top-color:#E0E0E0;border-top-style:solid;border-top-width:1px;">
        </eo:MenuItem>
    </LookItems>
</eo:ContextMenu>
<input id="hdnMessage" runat="server" type="text" visible="false" />
<asp:RequiredFieldValidator ID="rfvDatePicker" runat="server" CssClass="validator_text" Display="Dynamic" ForeColor=""></asp:RequiredFieldValidator>
<asp:CustomValidator ID="cvDatePickerWithCurrentDate" runat="server" ClientValidationFunction="ValidateWithCurrentDate" ControlToValidate="DatePicker1"
    CssClass="validator_text" Display="dynamic" Enabled="false" ForeColor="">  </asp:CustomValidator>
<input id="hdnCalendarDate" runat="server" type="hidden" />
eo_support
Posted: Thursday, March 12, 2009 4:03:21 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

This is a code error. You need to move the JavaScript function outside of the user control. Otherwise when the second instance of your user control is rendered, it overwrites the body of the JavaScript functions rendered by the first user control. The following post explained this in detail:

http://www.essentialobjects.com/forum/postst830_DatePicker-Error.aspx#7171

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.