C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

Javascript calendar control


Posted Date: 01 Oct 2008      Posted By: anand kumar      Member Level: Gold     Points: 1   Responses: 2



Hi,

i need calendar control using javascript code i need to get Pop -up window to select user from calendar control.


Regards
ANAND





Responses

Author: Abhay    01 Oct 2008Member Level: DiamondRating: 4 out of 54 out of 54 out of 54 out of 5     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
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Database+ primary key foreigm key relationship
Previous : sqlserver 2005
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use