programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Website by URL, How to Play YouTube Videos in by using Jquery , Jquery Change div background on mouseover in , JQuery UI Datepicker (Calendar) etc.

Monday, February 10, 2014

Display selected Date from data base into calendar

Display selected Date from data base into calendar in Programming:

 In the ASP.NET Programming we can easily access holiday list from data base, but here we goes to discuss how to bind these holiday’s in to calendar tool. As we know that calendar is use for representing to the data time in

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

This line use for register ajax toolkit in the page :

The Calendar control is used to display a calendar in the browser.This control displays a one-month calendar that allows the user to select dates and move to the next and previous months.
The Calendar control display a graphic calendar on which users can select dates. This control exists within System.

Web.UI.WebControls namespace. You can use the Calendar control to display a single month of a calendar on a Web page . This control allows you to select dates and move to the next or previous month. By Setting the SelectionMode property , You can select a single day , week, or month.

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

This line use for register ajax toolkit in the page :

Code for ASPX File:

<asp:UpdatePanel ID="up1" runat="server">
                                        <asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="White"
                                            BorderStyle="None" BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black"
                                            Height="219px" NextPrevFormat="ShortMonth" OnDayRender="Calendar1_DayRender"
                                            TitleFormat="MonthYear" Width="100%">
                                            <DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
                                            <NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333" VerticalAlign="Bottom" />
                                            <OtherMonthDayStyle ForeColor="#999999" />
                                            <SelectedDayStyle BackColor="#333399" ForeColor="White" />
                                            <TitleStyle BackColor="White" Font-Bold="true" Font-Size="11pt" ForeColor="#333399"
                                                HorizontalAlign="Center" VerticalAlign="Middle" />
                                            <TodayDayStyle BackColor="#CCCCCC" />
                                        <cc1:RoundedCornersExtender ID="Calendar1_RoundedCornersExtender" runat="server"
                                            Enabled="True" TargetControlID="Calendar1">

Code for ASPX.CS File:

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
        Literal l = new Literal();
        l.Visible = true;
        //l.Text = "<br/>";
        dt = (DataTable)ViewState["dt"];
        foreach (DataRow row in dt.Rows)
            if (Convert.ToDateTime(row[0].ToString()).ToShortDateString() == e.Day.Date.ToShortDateString())
                Label lb = new Label();
                lb.Visible = true;
                String s = row[1].ToString();
                s = s.Substring(0, 0);
                lb.Text = s.ToString();
                s = "";
                lb.Text = row[2].ToString();
                e.Cell.BackColor = System.Drawing.Color.FromArgb(132, 207, 150);
                e.Cell.ForeColor = System.Drawing.Color.WhiteSmoke;
    } related post:

No comments:

Post a Comment