Monthly Event Calendar – Control parameter query

Description:

ASP.NET Toolbox calendar control which use control parameter to query db records and display event(s) on calander item selection change. This is suitable for deisplaying events on PostBack call on the same page.

Elements:

  1. Events.mdb / or MS SQL
  2. Web.config
  3. Month-2.aspx
  4. Month-2.aspx.vb
  5. Dtgrid.css

Method:

  1. Create table Events (Id [primary key – AutoNumber], Event [Text], DateFrom [Date/Time], DateTo[Date/Time].
  2. Enter some data in the table
  1. Create/re-write web.config file (download web.config file here)
  2. Add New Item and name it Month-2.aspx or whatever you like
  3. Import dtgrig.css (downolad dtgrid.css file here)
  4. Drag calendar control from toolbox to designer
  5. Double click designer and in code behind create two subs: Page_Load and Calender1_SelectionChanged

  1. Drag “Events” table from Server Explorer to designer; Configure Data Source WHERE DateFrom = Control  – Calendar1 and add it to a SQL expression.
  2. Configure css property for your calendar and grid view and you are good to go.

Form Drop-down-list binding

Learn how to make easy drop-down-list with a list of different choices and binding the existing data with the form.

Screenshot speaks for itself.

Form Validation

Regular Expression Validator – Date Validation

TextBox Control

<asp:TextBox ID=”REF_PAID_DATETextBox” runat=”server”  Text='<%# Bind(“REF_PAID_DATE”) %>’ ToolTip=”Use MM/DD/YYYY format”  class=”myTextBox75″ ></asp:TextBox>

Regular Expression Validator

<asp:RegularExpressionValidator ID=”REF_PAID_DATEFormat” runat=”server”
ValidationExpression=”^\d{1,2}/\d{1,2}/\d\d\d\d$”
ControlToValidate=”REF_PAID_DATETextBox”
ValidationGroup=”Form1″ Text=” <font color=’red’> mm/dd/yyyy </font>”
ErrorMessage=”<font color=’red’> mm/dd/yyyy </font>”>
</asp:RegularExpressionValidator>

Submit Button

<asp:Button ID=”UpdateButton” runat=”server” CausesValidation=”True” ValidationGroup=”Form1″ CommandName=”Update” Text=”Update” />