VB Style Calendar in ASP.NET
Hi in this article I will create the old style calendar control which was there in VB 6.0 using little bit of JavaScript check out……..Actually this idea was not mine it was from my professor,any how check out………………
Default.aspx
| <%@ Page Language=”VB” AutoEventWireup=”false” CodeFile=”Default.aspx.vb” Inherits=”_Default” %>
<!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 id=”Head1″ runat=”server”> <script type=”text/javascript”> function displayCalendar() { var datePicker = document.getElementById(‘datePicker’); datePicker.style.display = ‘block’; }
</script> <style type=”text/css”> #datePicker { display:none; position:absolute; border:solid 2px black; background-color:white; } .content { width:400px; background-color:white; margin:auto; padding:10px; } html { background-color:silver; } </style> <title>Calendar with JavaScript</title> </head> <body> <form id=”form1″ runat=”server”> <div>
<asp:Label id=”lblEventDate” Text=”Event Date:” AssociatedControlID=”txtEventDate” Runat=”server” /> <asp:TextBox id=”txtEventDate” Runat=”server” />
<img src=”Images/Calendar.gif” onclick=”displayCalendar()” style=”width: 16px; height: 17px” />
<div id=”datePicker”> <asp:Calendar id=”calEventDate”
Runat=”server” /> </div>
<br /> <asp:Button id=”btnSubmit” Text=”Submit” Runat=”server” />
<hr />
<asp:Label id=”lblResult” Runat=”server” />
</div> </form> </body> </html>
|
Default.aspx.vb
| Partial Class _Default
Inherits System.Web.UI.Page Protected Sub calEventDate_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles calEventDate.SelectionChanged txtEventDate.Text = calEventDate.SelectedDate.ToString(“d”) End Sub
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click lblResult.Text = “You picked: ” & txtEventDate.Text End Sub End Class |

