Hi cdhenderson and thanks for your reply,
Yes the ASPX page works fine, but i wanted to convert it into custom control using the same concept. Here the ASCX file, I am not familiar with javascript so i believe i am calling the javascript incorrectly. I got the javascript from this site (
http://www.mattkruse.com/javascript/calendarpopup/)
and it is too big to add it here.
here is ASCX files
Thanks for you help
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class controls_MyDatePicker : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
string clientscript = "javascript
:return (cal.select(document.getElementById['txtDate'].txtDate,'anchor1','d/MMM/yyyy'); return false;";
CalendarImg.Attributes.Add("onclick", clientscript);
}
/// <summary>
/// The text box that the selected date resides in
/// </summary>
public TextBox DateTextBox
{
get
{
return txtDate;
}
}
}
-------------------------------------------------------------
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MyDatePicker.ascx.cs" Inherits="controls_MyDatePicker" %>
<script language="JavaScript" src="../javascript/CalendarPopup.
js"></script>
<script language="JavaScript">
var cal = new CalendarPopup();
</script>
<div >
<asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
<a href="../javascript/CalendarPopup.
js" onclick="cal.select(document.getElementById['txtDate'].txtDate,'anchor1','MM/dd/yyyy'); return false;"
name="anchor1" id="anchor1"> <asp:Image ID="CalendarImg" runat=server ImageAlign=AbsMiddle ImageUrl="~/calendar/calendar.gif" /></a>
</div>