2013-07-16 2 views
0

다음 .net 코드를 사용했습니다. 내가 데이터베이스에 저장하는 휴일 날짜를 보여주는. 그러나 날짜에 마우스를 가져 가면 몇 가지 메시지가 표시됩니다. 이 코드를 사용하여날짜에 마우스를 올리면 메시지가 표시됩니다.

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Data; 
using System.Data.SqlClient; 

public partial class _Default : System.Web.UI.Page 
{ 
string connection = @"server=TOPHAN-PC; Database=Tophan;uid=sa;pwd=123"; 
SqlConnection con = null; 
protected DataSet dsHolidays; 

protected void Page_Load(object sender, EventArgs e) 
{ 
    if (!IsPostBack) 
    { 

     con = new SqlConnection(connection); 
     Calendar1.VisibleDate = DateTime.Today; 
     FillHolidayDataset(); 
    } 
} 

protected void FillHolidayDataset() 
{ 
    DateTime firstDate = new DateTime(Calendar1.VisibleDate.Year,  Calendar1.VisibleDate.Month, 1); 
    DateTime lastDate = GetFirstDayOfNextMonth(); 
    dsHolidays = GetCurrentMonthData(firstDate, lastDate); 
} 

protected DateTime GetFirstDayOfNextMonth() 
{ 
    int monthNumber, yearNumber; 
    if (Calendar1.VisibleDate.Month == 12) 
    { 
     monthNumber = 1; 
     yearNumber = Calendar1.VisibleDate.Year + 1; 
    } 
    else 
    { 
     monthNumber = Calendar1.VisibleDate.Month + 1; 
     yearNumber = Calendar1.VisibleDate.Year; 
    } 
    DateTime lastDate = new DateTime(yearNumber, monthNumber, 1); 
    return lastDate; 
} 

protected DataSet GetCurrentMonthData(DateTime firstDate, DateTime lastDate) 
{ 
    DataSet dsMonth = new DataSet(); 
    try 
    {    
     //ConnectionStringSettings cs; 
     //cs = ConfigurationManager.ConnectionStrings["ConnectionString1"]; 
     //String connString = cs.ConnectionString; 
     //SqlConnection dbConnection = new SqlConnection(connString); 

     String query = "SELECT CDate FROM calender WHERE CDate >= @firstDate AND CDate < @lastDate"; 
     con.Open(); 
     SqlCommand dbCommand = new SqlCommand(query, con); 
     dbCommand.Parameters.Add(new SqlParameter("@firstDate", 
      firstDate)); 
     dbCommand.Parameters.Add(new SqlParameter("@lastDate", lastDate)); 

     SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(dbCommand); 
     sqlDataAdapter.Fill(dsMonth);      
    } 
    catch 
    { } 
    return dsMonth; 
} 


protected void Calendar1_VisibleMonthChanged(object sender, 
    MonthChangedEventArgs e) 
{ 
    FillHolidayDataset(); 
} 
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e) 
{ 
    try 
    { 
     DateTime nextDate; 
     if (dsHolidays != null) 
     { 
      foreach (DataRow dr in dsHolidays.Tables[0].Rows) 
      { 
       nextDate = (DateTime)dr["CDate"]; 
       if (nextDate == e.Day.Date) 
       { 
        e.Cell.BackColor = System.Drawing.Color.Pink; 

       } 
      } 
     } 
    } 
    catch 
    { } 
} 
} 

, 나는 그것이 색으로 날짜를 강조 것을 알아하지만 난 날짜에 ​​마우스를 이동할 때 나는 몇 가지 메시지를합니다.

+0

당신은 약간의 정적 메시지를 표시 할 수 있습니까? 그렇다면 jQuery로 쉽게 할 수 있습니다! 심지어 동적 메시지에서도 동적 인 내용이 페이지의 어딘가에 있으면 jQuery로 처리 할 수 ​​있습니다. – Aisha

+0

이 쿼리에 도움이되는 정보가 있습니다. – Sabyasachi

+0

일부 정적 메시지를 설정할 수 있다면 나중에 동적으로 설정할 수 있습니다. jQuery 코드가 있으면 코드를 공유하십시오. @Aisha – Sabyasachi

답변

0

이 그것을 할 수 있습니다

$(document).ready(function() 
{  
    $("#holiday").hover(function() { 
    //Show whatever message on hover in 
    }, 
    function() { 
    //Show whatever message on hover out 
    } 
); }); 
+0

내 페이지에서 기본 asp.net 달력 컨트롤을 사용했습니다. 그래서이 코드와 기본 jQuery를 사용해야하는 곳에서 페이지에 링크해야합니다. @Aisha – Sabyasachi

관련 문제