How to Make Customise Calender Control In Asp.net2.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • singh79
    New Member
    • Jul 2007
    • 16

    How to Make Customise Calender Control In Asp.net2.0

    Pls Any One Give Me Ans


    I want to Make Customise calender Control in Asp.net2.0 with the Help of C#.
    and I want to increse ind Decrease Year By Particular Tab.


    Regards & Thanks

    Atul singh
  • gchq
    New Member
    • Jan 2007
    • 96

    #2
    This is how to do it in VB - I'll leave it to you to convert

    aspx page (with dropdownlists added)

    Code:
    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="PlanCalendar.aspx.vb" Inherits="Test_PlanCalendar" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            &nbsp;<asp:Panel ID="Panel1" runat="server" BackColor="#E0E0E0" BorderStyle="Ridge"
                Height="130px" HorizontalAlign="Center" Width="361px">
            <table style="width: 351px">
                <tr>
                    <td colspan="3">
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:DropDownList ID="drpCalMonth" runat="server" AutoPostBack="True">
                        </asp:DropDownList></td>
                    <td>
                        </td>
                    <td style="text-align: right">
                        <asp:DropDownList ID="drpCalYear" runat="server" AutoPostBack="True">
                        </asp:DropDownList></td>
                </tr>
                <tr>
                    <td colspan="3">
                        &nbsp;<asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="White" BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black" Height="190px" NextPrevFormat="FullMonth" Width="350px">
                            <SelectedDayStyle BackColor="#333399" ForeColor="White" />
                            <TodayDayStyle BackColor="#CCCCCC" />
                            <OtherMonthDayStyle ForeColor="#999999" />
                            <NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333" VerticalAlign="Bottom" />
                            <DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
                            <TitleStyle BackColor="White" BorderColor="Black" BorderWidth="4px" Font-Bold="True"
                                Font-Size="12pt" ForeColor="#333399" />
                        </asp:Calendar>
                    </td>
                </tr>
            </table>
            </asp:Panel>
        
        </div>
        </form>
    </body>
    </html>
    Code Behind

    Code:
    Partial Class Test_PlanCalendar
        Inherits System.Web.UI.Page
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not Page.IsPostBack Then
                Call Populate_MonthList()
    
                Call Populate_YearList()
            End If
    
        End Sub
    
        Sub Set_Calendar(ByVal Sender As Object, ByVal E As EventArgs)
    
            'Whenever month or year selection changes display the calendar for that month/year        
            Calendar1.TodaysDate = CDate(drpCalMonth.SelectedItem.Value & " 1, " & drpCalYear.SelectedItem.Value)
    
        End Sub
        
        Sub Populate_MonthList()
            'Add each month to the list
            drpCalMonth.Items.Add("January")
            drpCalMonth.Items.Add("February")
            drpCalMonth.Items.Add("March")
            drpCalMonth.Items.Add("April")
            drpCalMonth.Items.Add("May")
            drpCalMonth.Items.Add("June")
            drpCalMonth.Items.Add("July")
            drpCalMonth.Items.Add("August")
            drpCalMonth.Items.Add("September")
            drpCalMonth.Items.Add("October")
            drpCalMonth.Items.Add("November")
            drpCalMonth.Items.Add("December")
    
    
            'Make the current month selected item in the list
            drpCalMonth.Items.FindByValue(MonthName(DateTime.Now.Month)).Selected = True
        End Sub
    
    
        Sub Populate_YearList()
            Dim intYear As Integer
    
            'Year list can be changed by changing the lower and upper 
            'limits of the For statement    
            For intYear = DateTime.Now.Year - 20 To DateTime.Now.Year + 20
                drpCalYear.Items.Add(intYear)
            Next
    
            'Make the current year selected item in the list
            drpCalYear.Items.FindByValue(DateTime.Now.Year).Selected = True
        End Sub

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      I have moved your question to the .NET forum. The .NET Articles section is reserved for articles that are purely informational; like "how-tos" etc. The .NET Forum is the place for your questions. In the future please post your questions here (Blue Menu Along the Top: Forums->.NET).

      Thanks

      -Frinny

      Comment

      Working...