Click here to Skip to main content
15,844,387 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear All,
I want to display a popup message when user place the mouse on a date in the calender control.
Popup is showing but is blinking very fast.
Massage having hyperlink which redirect to other page.

Please help me ASAP.

Aspx Code:
XML
<script language="javascript" type="text/javascript">

        function ShowModalPopup() {
            $find("ModalBehaviour").show();
        }

        function HideModalPopup() {
            $find("ModalBehaviour").hide();
        }

    </script>
    <div>
        <asp:Calendar ID="CalView" runat="server" BackColor="#FF6600" BorderColor="#336600"
            Height="400px" BorderStyle="Solid" BorderWidth="2px" DayNameFormat="Full" OnDayRender="CalView_DayRender"
            OnSelectionChanged="CalView_SelectionChanged" OnVisibleMonthChanged="CalView_VisibleMonthChanged"
            ShowGridLines="True" Width="793px"></asp:Calendar>
    </div>
    <asp:Panel ID="Panel1" runat="server">
        <div>
            <table border="1">
                <tr>
                    <td>
                        Case Hearing:
                    </td>
                    <td>
                        <asp:HyperLink ID="hylCaseHearing" Text="1" runat="server"></asp:HyperLink>
                    </td>
                </tr>
                <tr>
                    <td>
                        Notice Reply:
                    </td>
                    <td>
                        <asp:HyperLink ID="hylNoticeReply" Text="2" runat="server"></asp:HyperLink>
                    </td>
                </tr>
                <tr>
                    <td>
                        Contract Expiry:
                    </td>
                    <td>
                        <asp:HyperLink ID="hylContractExpire" Text="3" runat="server"></asp:HyperLink>
                    </td>
                </tr>
                <tr>
                    <td>
                        IPR Expiry:
                    </td>
                    <td>
                        <asp:HyperLink ID="hplIPRExpire" Text="4" runat="server"></asp:HyperLink>
                    </td>
                </tr>
            </table>
        </div>
    </asp:Panel>
    <cc1:ModalPopupExtender PopupControlID="Panel1" TargetControlID="Panel1" ID="ModalPopupExtender1"
        BehaviorID="ModalBehaviour" runat="server">
    </cc1:ModalPopupExtender>
</asp:Content>


Code Behind Page Code:

C#
public partial class CalendarView : System.Web.UI.Page
    {
        private List<datetime> AllDate = new List<datetime>();

        private List<string> CaseHearingCount = new List<string>();
        private List<string> NoticeFinalReplyCount = new List<string>();
        private List<string> ContractExpiryCount = new List<string>();
        private List<string> IPRExpiryCount = new List<string>();

        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                GetData();
            }

        }

        public void GetData()
        {
            DataSet Ds = new DataSet();
            Ds = LCMSSqlQuery.SP_CalendarView();

            for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
            {
                AllDate.Add(Convert.ToDateTime(Ds.Tables[0].Rows[i][0]));

                CaseHearingCount.Add(Convert.ToString(Ds.Tables[0].Rows[i][1]));
                NoticeFinalReplyCount.Add(Convert.ToString(Ds.Tables[0].Rows[i][2]));
                ContractExpiryCount.Add(Convert.ToString(Ds.Tables[0].Rows[i][3]));
                IPRExpiryCount.Add(Convert.ToString(Ds.Tables[0].Rows[i][4]));



            }

        }
        protected void CalView_SelectionChanged(object sender, EventArgs e)
        {

        }

        protected void CalView_DayRender(object sender, DayRenderEventArgs e)
        {
            string tooltip = string.Empty;
            if (IsEventDay(e.Day.Date, out tooltip, e))
            {
                e.Cell.BackColor = System.Drawing.Color.Pink;
                e.Day.IsSelectable = false;
                e.Cell.ToolTip = tooltip;


            }
            //if (e.Day.IsWeekend)
            //{
            //    e.Cell.BackColor = System.Drawing.Color.Black;
            //    e.Cell.ForeColor = System.Drawing.Color.White;
            //    e.Day.IsSelectable = false;
            //}
        }

        private bool IsEventDay(DateTime day, out string tooltipvalue, DayRenderEventArgs e)
        {

            tooltipvalue = string.Empty;
            for (int i = 0; i < AllDate.Count; i++)
            {
                if (AllDate[i] == day)
                {
                    string URL = "ViewCount.aspx?Date=" + AllDate[i].ToString() + "&CaseHearingCount=" + CaseHearingCount[i].ToString() + "&NoticeFinalReplyCount=" + NoticeFinalReplyCount[i].ToString() + "&ContractExpiryCount=" + ContractExpiryCount[i].ToString() + "&IPRExpiryCount=" + IPRExpiryCount[i].ToString() + "";

                    hylCaseHearing.Text = CaseHearingCount[i].ToString();
                    hylCaseHearing.NavigateUrl = URL;
                    hylNoticeReply.Text = NoticeFinalReplyCount[i].ToString();
                    hylNoticeReply.NavigateUrl = URL;
                    hylContractExpire.Text = ContractExpiryCount[i].ToString();
                    hylContractExpire.NavigateUrl = URL;
                    hplIPRExpire.Text = IPRExpiryCount[i].ToString();
                    hplIPRExpire.NavigateUrl = URL;

                    //e.Cell.Attributes.Add("onmouseover", "javascript:alert('Today')");

                    e.Cell.Attributes.Add("onMouseOver", "javascript:ShowModalPopup();");
                    e.Cell.Attributes.Add("onMouseLeave", "javascript:HideModalPopup();");

                    //tooltipvalue = "Case Count- " + CaseHearingCount[i];
                    return true;
                }


            }
            return false;
        }

        protected void CalView_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
        {
            int a = e.NewDate.Month;
            int b = e.NewDate.Year;
            GetData();
        }
    }
Posted
Updated 26-Jun-14 21:00pm
v2
Comments
Sergey Alexandrovich Kryukov 26-Jun-14 13:49pm    
What is that, "calender control"? :-)
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900