Welcome Guest Search | Active Topics | Sign In | Register

datepicker title and footer ClientSideOnItemClick not enter to function Options
r.d.e.eventact.com
Posted: Tuesday, March 9, 2010 6:13:08 AM
Rank: Newbie
Groups: Member

Joined: 3/7/2010
Posts: 7
Code: C#
using System;
using System.ComponentModel;
using System.Security.Permissions;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using EO.Web;


[assembly: TagPrefix("Eventact.Forms.InputControls", "eaf")]
namespace Eventact.Forms.Common
{
    [AspNetHostingPermission(SecurityAction.Demand,
        Level = AspNetHostingPermissionLevel.Minimal),
    AspNetHostingPermission(SecurityAction.InheritanceDemand,
        Level = AspNetHostingPermissionLevel.Minimal), DefaultProperty("Value"),
    ValidationPropertyAttribute("Value"),
     ToolboxData("<{0}:DateInput runat=\"server\"> </{0}:DateInput>")]
    public class DateInput : CompositeControl
    {
        #region private varibale
        private EO.Web.DatePicker _calendarEo;
        private ContextMenu _mnuMonth;
        private ContextMenu _mnuYear;
        #endregion

        #region properties

        protected override HtmlTextWriterTag TagKey
        {
            get
            {
                return HtmlTextWriterTag.Table;
            }
        }


        public  object Value
        {
            get
            {
                EnsureChildControls();
                    return _calendarEo.SelectedDate;
            }
            set
            {
                EnsureChildControls();
                DateTime date = DateTime.MinValue;
                if (value != null &&
                   DateTime.TryParse(value.ToString(), out date) && date != DateTime.MinValue)
                {
                    _calendarEo.SelectedDate = date;
                    _calendarEo.VisibleDate = date;
                }
            }
        }

        public static Type ValueType
        {
            get
            {
                return typeof(DateTime);
            }
        }

        #endregion

        #region constructors
        public DateInput()
        {
            this.ID = "DateInput";
        }

        public DateInput(int fieldID)
        {
            this.ID = "DateInput";
        }
        #endregion

        public override void DataBind()
        {
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            EnsureChildControls();
        }

        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            _calendarEo = new EO.Web.DatePicker();
            _calendarEo.ID = "_calendarEo";
            _calendarEo.AllowMultiSelect = false;
            _calendarEo.TitleRightArrowDownImageUrl = "00040104";
            _calendarEo.MonthSelectorVisible = false;
            _calendarEo.DayCellHeight = 20;
            _calendarEo.DayCellWidth = 30;
            _calendarEo.WeekSelectorVisible = false;
            _calendarEo.TitleLeftArrowDownImageUrl = "00040103";
            _calendarEo.DayHeaderFormat = DayNameFormat.Short;


            _calendarEo.TitleTemplate = new ClientTemplate();
            _calendarEo.TitleTemplate.Text = "<center>{var:visible_date:MMMM}" +
                    "<a id=\"{var:clientId}_month\" href=\"javascript:ShowMonthPopup('{var:clientId}', '{var:clientId}_month')\">" +
                    " <img src=\"{img:00020012}\" border='0' /></a>" +
                    "{var:visible_date:yyyy}<a id=\"{var:clientId}_year\" href=\"javascript:ShowYearPopup('{var:clientId}', '{var:clientId}_year')\">" +
                    "<img src=\"{img:00020012}\" border='0' /></a></center>";


                _calendarEo.TitleLeftArrowImageUrl = "00040206";
                _calendarEo.TitleRightArrowImageUrl = "00040204";
                _calendarEo.TitleLeftArrowHoverImageUrl = "00040207";
                _calendarEo.TitleRightArrowHoverImageUrl = "00040205";
                _calendarEo.TitleLeftArrowDownImageUrl = "00040207";
                _calendarEo.TitleRightArrowDownImageUrl = "00040205";
            EO.Web.ClientTemplate a = new EO.Web.ClientTemplate();
            HtmlImage img = new HtmlImage();
            img.Src = "{img:00040106}";
            a.Controls.Add(img);
            _calendarEo.FooterTemplate = a;
            _calendarEo.DayStyle.CssText = "text-decoration:none";
            _calendarEo.DayHoverStyle.CssText = "background-image:url('00040208');";
            _calendarEo.DisabledDayStyle.CssText = "COLOR: gray";
            _calendarEo.DayHeaderStyle.CssText = "FONT-SIZE: 11px; COLOR: #0054e3; BORDER-BOTTOM: black 1px solid; FONT-FAMILY: Tahoma";
            _calendarEo.SelectedDayStyle.CssText = "background-image:url('00040208');";
            _calendarEo.MonthStyle.CssText = "FONT-SIZE: 8pt; MARGIN: 0px 4px; FONT-FAMILY: Tahoma; cursor:hand";
            _calendarEo.TitleStyle.CssText = "PADDING-RIGHT: 3px; PADDING-LEFT: 3px; FONT-WEIGHT: bold; FONT-SIZE: 8pt; PADDING-BOTTOM: 3px; COLOR: white; PADDING-TOP: 3px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #0054e3";
            _calendarEo.CalendarStyle.CssText = "border-bottom-color:Black;border-bottom-style:solid;border-bottom-width:1px;border-left-color:Black;border-left-style:solid;border-left-width:1px;border-right-color:Black;border-right-style:solid;border-right-width:1px;border-top-color:Black;border-top-style:solid;border-top-width:1px;padding-bottom:5px;padding-left:5px;padding-right:5px;padding-top:5px;background-color:white";
            _calendarEo.TodayStyle.CssText = "background-image:url('00040106');";
            _calendarEo.PopupHoverImageUrl = "00040211";
            _calendarEo.TitleLeftArrowHoverImageUrl = "00040205";
            _calendarEo.PopupImageUrl = "00040209";
            _calendarEo.PopupDownImageUrl = "00040210";

            System.Globalization.CultureInfo info = System.Threading.Thread.CurrentThread.CurrentCulture;
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("he-IL");
            _calendarEo.PickerHint = "";// DateTime.Now.ToString("d");
            System.Threading.Thread.CurrentThread.CurrentCulture = info;

            _calendarEo.PickerFormat = "dd/MM/yyyy";

            Controls.Add(_calendarEo);

            createMonthMenu();
            createYearMenu();
        }

        private void LoadMenuMonths(ref EO.Web.ContextMenu cmMnuMonth)
        {
            try
            {
                //Add the below code in page_load event
                string[] months = new string[12];
                months[0] = "January";
                months[1] = "February";
                months[2] = "March";
                months[3] = "April";
                months[4] = "May";
                months[5] = "June";
                months[6] = "July";
                months[7] = "August";
                months[8] = "September";
                months[9] = "October";
                months[10] = "November";
                months[11] = "December";
                if (cmMnuMonth != null)
                {
                    cmMnuMonth.Items.Clear();
                }

                foreach (string month in months)
                {
                    EO.Web.MenuItem item = new EO.Web.MenuItem();
                    item.Text.Html = month;
                    cmMnuMonth.Items.Add(item);
                }
            }
            catch (Exception e)
            {

            }
        }

        private void createMonthMenu()
        {
            _mnuMonth = new ContextMenu();
            _mnuMonth.ID = "mnuMonth" + _calendarEo.ID;
            _mnuMonth.ControlSkinID = "None";
            _mnuMonth.Style.Add(HtmlTextWriterStyle.Width, "80");
            _mnuMonth.ClientSideOnItemClick = "javascript:return MonthMenuClicked(event,this);";
            _mnuMonth.TopGroup.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;";
            _mnuMonth.TopGroup.OffsetX = 115;
            _mnuMonth.TopGroup.OffsetY = -100;
            LoadMenuMonths(ref _mnuMonth);

            EO.Web.MenuItem mnuMonth = new EO.Web.MenuItem();
            mnuMonth.HoverStyle.CssText = "color:#1C7CDC;padding-left:5px;padding-right:5px;";
            mnuMonth.ItemID = "_Default";
            mnuMonth.NormalStyle.CssText = "color:#2C0B1E;padding-left:5px;padding-right:5px;";
            mnuMonth.SubMenu.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;";
            mnuMonth.SubMenu.ShadowDepth = 0;
            mnuMonth.SubMenu.ItemSpacing = 5;

            _mnuMonth.LookItems.Add(mnuMonth);
            Controls.Add(_mnuMonth);
        }

        private void createYearMenu()
        {
            _mnuYear = new ContextMenu();

            _mnuYear.ID = "mnuYear" + _calendarEo.ID;
            _mnuYear.ControlSkinID = "None";
            _mnuYear.Style.Add(HtmlTextWriterStyle.Width, "80px");
            _mnuYear.ClientSideOnItemClick = "javascript:return YearMenuClicked(event,this);";
            _mnuYear.EnableScrolling = true;
            _mnuYear.ScrollUpLookID = "scroll_up" + _calendarEo.ID;
            _mnuYear.ScrollDownLookID = "scroll_down" + _calendarEo.ID;
            _mnuYear.TopGroup.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;";
            _mnuYear.TopGroup.OffsetX = 168;
            _mnuYear.TopGroup.Height = 150;
            _mnuYear.TopGroup.OffsetY = -50;

            int MinValidYear = 1980;
            int MaxValidYear = 2010;

            EO.Web.MenuItem mnuYear = new EO.Web.MenuItem();
            mnuYear.HoverStyle.CssText = "color:#1C7CDC;padding-left:5px;padding-right:5px;";
            mnuYear.ItemID = "_Default";
            mnuYear.NormalStyle.CssText = "color:#2C0B1E;padding-left:5px;padding-right:5px;";
            mnuYear.SubMenu.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;";
            mnuYear.SubMenu.ShadowDepth = 0;
            mnuYear.SubMenu.ItemSpacing = 5;

            EO.Web.MenuItem mnuYearScrollDown = new EO.Web.MenuItem();
            mnuYearScrollDown.Height = 14;
            mnuYearScrollDown.ItemID = "scroll_down";
            mnuYearScrollDown.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;";
            mnuYearScrollDown.Image.Url = "00020001";

            EO.Web.MenuItem mnuYearScrollUp = new EO.Web.MenuItem();
            mnuYearScrollUp.Height = 14;
            mnuYearScrollUp.ItemID = "scroll_up";
            mnuYearScrollUp.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;";
            mnuYearScrollUp.Image.Url = "00020000";

            for (int i = MinValidYear; i <= MaxValidYear; i++)
            {
                EO.Web.MenuItem item = new EO.Web.MenuItem();
                item.Text.Html = i.ToString();
                _mnuYear.Items.Add(item);
            }

            _mnuYear.LookItems.Add(mnuYear);
            _mnuYear.LookItems.Add(mnuYearScrollDown);
            _mnuYear.LookItems.Add(mnuYearScrollUp);
            Controls.Add(_mnuYear);
        }

        protected override void RenderContents(HtmlTextWriter writer)
        {

            EnsureChildControls();
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            System.Web.UI.ScriptManager sm = System.Web.UI.ScriptManager.GetCurrent(Page);
            if (sm == null)
                this.Page.ClientScript.RegisterStartupScript(GetType(), this.ID, CalScript(_calendarEo.ID), true);
            else
                System.Web.UI.ScriptManager.RegisterStartupScript(Page, Page.GetType(), this.ID, CalScript(_calendarEo.ID), true);

            _calendarEo.RenderControl(writer);
            _mnuMonth.RenderControl(writer);
            _mnuYear.RenderControl(writer);
            writer.RenderEndTag();
            writer.RenderEndTag();

        }

        private string CalScript(string id)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("var g_curCalendar1 = null;");
            sb.Append("function ShowMonthPopup(calendar, refLink){");
            sb.Append("g_curCalendar = calendar;");
            sb.Append("var monthPicker = document.getElementById(refLink);");
            sb.Append("eo_GetObject(g_curCalendar).showContextMenu(monthPicker, \"mnuMonth" + id + "\");}");

            sb.Append("function MonthMenuClicked(e, info){");
            sb.Append("var month = info.getItem().getIndex(); var calendar = eo_GetObject(g_curCalendar);");
            sb.Append("var curMonth = calendar.getVisibleDate(); curMonth.setMonth(month); calendar.goTo(curMonth);}");

            sb.Append("function ShowYearPopup(calendar, refLink){");
            sb.Append("g_curCalendar = calendar; var yearPicker = document.getElementById(refLink);");
            sb.Append("eo_GetObject(g_curCalendar).showContextMenu(yearPicker, \"mnuYear" + id + "\");}");

            sb.Append("function YearMenuClicked(e, info){");
            sb.Append("var year = info.getItem().getIndex();var calendar = eo_GetObject(g_curCalendar);");
            sb.Append("var curMonth = calendar.getVisibleDate(); curMonth.setFullYear(year + 1980);calendar.goTo(curMonth);}");
            return sb.ToString();
        }

    }
}
eo_support
Posted: Tuesday, March 9, 2010 9:24:17 AM
Rank: Administration
Groups: Administration

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

ClientSideOnItemClick takes a function name, not inline JavaScript code. For example, this is wrong:

Code: JavaScript
_mnuMonth.ClientSideOnItemClick 
    = "javascript:return MonthMenuClicked(event,this);"


This is correct:

Code: JavaScript
_mnuMonth.ClientSideOnItemClick= "MonthMenuClicked";


The menu will pass all the arguments to the function. You can not change or pass any of your arguments to it.

Thanks!
r.d.e.eventact.com
Posted: Tuesday, March 9, 2010 10:16:20 AM
Rank: Newbie
Groups: Member

Joined: 3/7/2010
Posts: 7
hi thanks for replay.
i change for:_mnuMonth.ClientSideOnItemClick= "MonthMenuClicked";
also the year but still nothing happen when i select year or month from the menu
eo_support
Posted: Tuesday, March 9, 2010 10:25:32 AM
Rank: Administration
Groups: Administration

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

In that case you will need to debug it. The code is correct. We usually don't troubleshoot our user's code, but if you believe there is something wrong with the control itself, you can create a full repro project and we will be happy to take a look.

Thanks!
r.d.e.eventact.com
Posted: Wednesday, March 10, 2010 6:04:10 AM
Rank: Newbie
Groups: Member

Joined: 3/7/2010
Posts: 7
thanks it work


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.