鼠标悬停在日历控件中的日期上显示弹出消息 [英] Displaying a popup message on mouse hover on a date in calender control

查看:477
本文介绍了鼠标悬停在日历控件中的日期上显示弹出消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

当用户将鼠标放在日历控件中的日期时,我想显示一条弹出消息。

Popup正在显示但是快速闪烁。

按摩有超链接重定向到其它页面。



请尽快帮助我。



Aspx代码:

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:

<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:

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();
        }
    }

推荐答案

find(ModalBehaviour)。show();
}

函数HideModalPopup(){
find("ModalBehaviour").show(); } function HideModalPopup() {


find(ModalBehaviour)。hide();
}

< / script >
< div >
< asp:日历 < span class =code-attribute> ID = CalView runat = server BackColor = #FF6600 BorderColor = #336600

高度 = 400px BorderStyle = 实体 BorderWidth < span class =code-keyword> = 2px DayNameFormat = 完整 OnDayRender = < span class =code-keyword> CalView_DayRender

< span class =code-attribute> OnSelectionChanged = CalView_SelectionChanged OnVisibleMonthChanged = CalView_VisibleMonthChanged

< span class =code-attribute> ShowGridLines = True 宽度 = 793px > < / asp:日历 >
< / div >
< asp:Panel ID = Panel1 runat = server >
< div >
< table border = 1 >
< tr >
< td >
案例听证会:
< / td >
< td >
< asp:HyperLink ID = hylCaseHearing 文本 = 1 runat = server > < / asp:HyperLink >
< / td > ;
< / tr >
< tr >
&l t; td >
通知回复:
< / td >
< td >
< asp:HyperLink ID = hylNoticeReply 文字 = 2 runat = server > < / asp:HyperLink >
< / td>
</tr>
<tr>
<td>
Contract Expiry:
</td>
< < span class=\"code-leadattribute\">td>
<asp:HyperLink ID=\"hylContractExpire\" Text=\"3\" runat=\"server\"></asp:HyperLink>
</td>
</tr>
<tr>
<td>
IPR Expiry:
</td>
<td>
<asp:HyperLink ID=\"hplIPR Expire\" Text=\"4\" runat=\"server\"></asp:HyperLink>
</td>
</tr>
</table>
</di v>
</asp:Panel>
<cc1:ModalPopupExtender PopupControlID=\"Panel1\" TargetControlID=\"Panel1\" ID=\"ModalPopupExtender1\"

BehaviorID=\"ModalBehaviour\" runat=\"server\">
</cc1:ModalPopupExtender>
</asp:Content>
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:





Code Behind Page Code:

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();
        }
    }


这篇关于鼠标悬停在日历控件中的日期上显示弹出消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆