include a calendar in a form

Discussion in 'Programming' started by schlogo, Nov 17, 2007.

  1. #1
    Hello

    I need to produce a form with a calendar in it

    The users will be able to chose a starting date and an ending date for an event.

    The informations should be kept in a database

    If someone knows an existing script or is able to make one, please shout :D

    O
     
    schlogo, Nov 17, 2007 IP
  2. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Fairly simple to do... assume you want a calendar for each one but it would be easy to do it with one too

    
    <%@ Page Language="VB" %>
    <%@ Import Namespace="System.Data.SqlClient" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
    
        Protected Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            '''' insert to db
            Dim sqlconn As New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString"))
            Dim SqlQuery As String = "INSERT INTO yourtable (startdate, enddate) VALUES (@startdate, @endate)"
            Dim sqlcomm As New SqlCommand(SqlQuery, sqlconn)
            sqlcomm.Parameters.AddWithValue("startdate", Calendar1.SelectedDate)
            sqlcomm.Parameters.AddWithValue("endate", Calendar2.SelectedDate)
            sqlconn.Open()
            sqlcomm.ExecuteNonQuery()
            sqlconn.Close()
            
            '''' do something else
            
        End Sub
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            Start Date:<asp:Calendar ID="Calendar1" runat="server" />
            End Date:<asp:Calendar ID="Calendar2" runat="server" />
            <asp:Button ID="button1" runat="server" Text="submit" OnClick="button1_Click" />
        </div>
        </form>
    </body>
    </html>
    
    Code (.Net):
    obviously you would want to add error handling, validation etc but its the idea
     
    AstarothSolutions, Nov 17, 2007 IP
  3. schlogo

    schlogo Well-Known Member

    Messages:
    1,615
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    140
    #3
    thanks for your answer, it actually sounds simple :D But I guess I ll pay someone to do it for me :D
     
    schlogo, Nov 18, 2007 IP