| Author: Abhay 01 Oct 2008 | Member Level: Diamond | Rating:    Points: 6 |
clientside code:
javascript function:
function ShowCalendar(oCalendarTextBox) { if( oCalendarTextBox.value != "") {
oCalendarTextBox.value = "";
}
if ( oCalendarTextBox.value == "" ) {
var oDate = new Date(); oCalDate=(oDate.getMonth()+1) + '/' + oDate.getDate() + '/' + oDate.getFullYear();
} else { // Check if not valid date then shoe todays date
if(DateIsValid(oCalendarTextBox.value)) {
oCalDate=oCalendarTextBox.value; } else{
var oDate = new Date(); oCalDate=(oDate.getMonth()+1) + '/' + oDate.getDate() + '/' + oDate.getFullYear(); }
}
var CalVal=window.showModalDialog(sRootPath + 'Image/Calendar.htm', oCalDate, 'dialogLeft:500px;dialogTop:500px;dialogHeight:219px;dialogWidth:265px;center:No;help:No;scroll:No;resizable:No;status:No;');
if(CalVal!="") {
oCalendarTextBox.value = CalVal; oCalendarTextBox.select(); oCalendarTextBox.focus(); } }
<td style="FONT-WEIGHT: bolder; FONT-STYLE: italic"> <asp:Label Runat="server" ID="lblpost" style="DISPLAY:none">POSTED FROM</asp:Label> <asp:textbox style="DISPLAY:none" id="txtfrom" Width="112px" Runat="server" ReadOnly="false" MaxLength="10" CssClass="txtBox"></asp:textbox> <IMG id="Imgfrom" onclick="ShowCalendar(document.getElementById('txtfrom'));" alt="Calendar" src="Image\calendar.gif" border="0" Runat="server" style="DISPLAY: none; CURSOR: hand"> <asp:Label Runat="server" ID="lblto" style="DISPLAY:none">TO</asp:Label> <asp:textbox id="txtto" Width="112px" Runat="server" ReadOnly="false" MaxLength="10" CssClass="txtBox" style="DISPLAY:none"></asp:textbox> <IMG id="Imgto" onclick="ShowCalendar(document.getElementById('txtto'));" alt="Calendar" src="Image\calendar.gif" border="0" Runat="server" style="DISPLAY: none; CURSOR: hand"> </td>
serverside: protected string sRootPath;
pageload:
Session["ROOT_PATH"] = Request.Url.Scheme + "://" + Request.Url.Host + Request.ApplicationPath + "/"; sRootPath = this.Session["ROOT_PATH"].ToString(); Page.RegisterClientScriptBlock("RootPath","<script language=javascript>var sRootPath='" + sRootPath + "';</script>");
put this attchmentfile in your project folder.
Thanks and Regards, Abhay
168210-30328-167566-27243-calendar.zip |