简体   繁体   中英

Calendar issue Asp.net (c#)

I have a problem with selecting a day in calendar.

When I click the day, the fonts of the page becoming bigger and bold than I expected, even the days of the calendar.

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        Calendar1.EnableViewState = false;
    }
}

protected void calendario1(object sender, DayRenderEventArgs e)
{
    if (e.Day.IsOtherMonth)
    {
        e.Cell.Controls.Clear();
    }

    // Change the background color of the days in the month to Red.
    if (e.Day.Date.DayOfWeek == DayOfWeek.Sunday || e.Day.Date.DayOfWeek == DayOfWeek.Saturday)
    {
        e.Cell.ForeColor = System.Drawing.Color.Red;
        e.Day.IsSelectable = false;
    }
}

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
    DateTime dt;

    dt = Calendar1.SelectedDate;

    //Response.Write("<script language=javascript>alert('"+ dt +"');</script>");
    Response.Write(dt);
}

HTML hTML CODE

UPDATE I commented the code at event "CALENDAR1_SELECTIONCHANGED" and the css stay normal. specifically "Response. write(alert...) ;

Seems to me that once you click the calender icon, some of the styles from the calender css is overriding the page's css classes. That is why you are getting bigger fonts. I could see in your pastebin code sample that you are using ajax control toolkit but I could not see the calender control there. I could see an update panel having gridview.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM