|
Hi,
I have been using your control for sometime now, and I think it's great. It is working fine with .Net 2 also. The problem I'm having is that when I place it in a aspx page that uses Master pages the .Text value is returned blank.
Do you have a fix?
Thanks
Chris
|
|
|
|
|
Hi Chris
Yes - I do have a fix - but this control needs to be rewritten from scratch anyway (working on it at the moment).
Will repost as soon as it's complete.
Cheers
Doug Wilson
|
|
|
|
|
Hi Doug,
I thank you for your reply. I do not want to sound annoying, however when do you think this will be available? Unfortunately I changed a large portion of our internal software before relising that there was an issue with the datepicker and it's kind of difficult to roleback.
Thanks
Christian Ransley BSc.
|
|
|
|
|
Just comment out
txtTextBox.ReadOnly = true;
Then add another javascript event that restricts values to be typed in.
Sully
-- modified at 1:34 Sunday 19th February, 2006
|
|
|
|
|
Chris,
I've been trying to get the code to work for sometime now. Everything looks okay, but the textbox value is not being passed to my update parameter (it is always null). Can you post the code that you've been using, or perhaps provide a suggestion?
Also, you may email the code to me if you would like at RGoodman@charter.net.
Many thanks,
Robert
|
|
|
|
|
Hello,
I fixed this control before by using the findcontrol method rather than just an index position but it broke when I tried it in my new ASP.NET 2.0 app. I used this as an excuse to make some improvements and fix it.
I have changed the method from building up the javascript to use a string builder which should speed things up quite a bit and also used the render method rather than composition which should make things faster but also means it works fine in asp.net v2. I've posted my code below, if anyone spots a problem with it then let me know.
Hope this helps!
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Collections.Specialized;
using System.Text;
namespace EblocControls
{
/// <summary>
/// Summary description for WebCustomControl1.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")]
public class DatePicker : WebControl, INamingContainer,IPostBackDataHandler
{
#region Private Properties
private string m_closeGif = "close.gif";
private string m_dividerGif = "divider.gif";
private string m_drop1Gif = "drop1.gif";
private string m_drop2Gif = "drop2.gif";
private string m_left1Gif = "left1.gif";
private string m_left2Gif = "left2.gif";
private string m_right1Gif = "right1.gif";
private string m_right2Gif = "right2.gif";
private string m_imgDirectory = "/img/";
private string m_ControlCssClass = "";
private string m_text = "";
private string m_Css = "";
private string m_DateType = "dd mmm yyyy";
#endregion
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Page.RegisterRequiresPostBack(this);
}
#region Public Properties
public string Text
{
get
{
return m_text;
}
set
{
m_text = value;
}
}
public virtual bool LoadPostData(string postDataKey, NameValueCollection values)
{
Page.Response.Write("Load post data has been hit"+UniqueID + "_DatePicker");
try
{
m_text = values[UniqueID + "_DatePicker"].ToString();
}
catch (Exception)
{
m_text ="working";
}
return false;
}
public virtual void RaisePostDataChangedEvent()
{
}
public override string CssClass
{
get
{
return m_Css;
}
set
{
m_Css = value;
}
}
public string imgClose
{
get {return m_closeGif;}
set {m_closeGif = value;}
}
public string imgDivider
{
get {return m_dividerGif;}
set {m_dividerGif = value;}
}
public string imgDrop1
{
get {return m_drop1Gif;}
set {m_drop1Gif = value;}
}
public string imgDrop2
{
get {return m_drop2Gif;}
set {m_drop2Gif = value;}
}
public string imgLeft1
{
get {return m_left1Gif;}
set {m_left1Gif = value;}
}
public string imgLeft2
{
get {return m_left2Gif;}
set {m_left2Gif = value;}
}
public string imgRight1
{
get {return m_right1Gif;}
set {m_right1Gif = value;}
}
public string imgDirectory
{
get {return m_imgDirectory;}
set {m_imgDirectory = value;}
}
public string ControlCssClass
{
get {return m_ControlCssClass;}
set {m_ControlCssClass = value;}
}
public string DateType
{
get {return m_DateType;}
set {m_DateType = value;}
}
#endregion
#region Constructors
public DatePicker()
{
//
// TODO: Add constructor logic here
//
}
#endregion
#region Private Methods/Properties
private void placeJavascript()
{
StringBuilder sbJavascript = new StringBuilder();
sbJavascript.Append("<script type=\"text/javascript\">");
sbJavascript.Append("// written by Tan Ling Wee on 2 Dec 2001\n");
sbJavascript.Append("// last updated 23 June 2002\n");
sbJavascript.Append("// email : fuushikaden@yahoo.com\n\n");
sbJavascript.Append("var fixedX = -1 // x position (-1 if to appear below control)\n");
sbJavascript.Append("var fixedY = -1 // y position (-1 if to appear below control)\n");
sbJavascript.Append("var startAt = 1 // 0 - sunday ; 1 - monday\n");
sbJavascript.Append("var showWeekNumber = 1 // 0 - don't show; 1 - show\n");
sbJavascript.Append("var showToday = 1 // 0 - don't show; 1 - show\n");
sbJavascript.Append(@"var imgDir = """ + m_imgDirectory + @"""" + "\n");
sbJavascript.Append(@"var gotoString = ""Go To Current Month""" + "\n");
sbJavascript.Append(@"var todayString = ""Today is""" + "\n");
sbJavascript.Append(@"var weekString = ""Wk""" + "\n");
sbJavascript.Append(@"var scrollLeftMessage = ""Click to scroll to previous month. Hold mouse button to scroll automatically.""" + "\n");
sbJavascript.Append(@"var scrollRightMessage = ""Click to scroll to next month. Hold mouse button to scroll automatically.""" + "\n");
sbJavascript.Append(@"var selectMonthMessage = ""Click to select a month.""" + "\n");
sbJavascript.Append(@"var selectYearMessage = ""Click to select a year.""" + "\n");
sbJavascript.Append(@"var selectDateMessage = ""Select [date] as date."" // do not replace [date], it will be replaced by date." + "\n");
sbJavascript.Append("var crossobj, crossMonthObj, crossYearObj, monthSelected, yearSelected, dateSelected, omonthSelected, oyearSelected, odateSelected, monthConstructed, yearConstructed, intervalID1, intervalID2, timeoutID1, timeoutID2, ctlToPlaceValue, ctlNow, dateFormat, nStartingYear\n\n");
sbJavascript.Append("var bPageLoaded=false\n");
sbJavascript.Append("var ie=document.all\n");
sbJavascript.Append("var dom=document.getElementById\n\n");
sbJavascript.Append("var ns4=document.layers\n");
sbJavascript.Append("var today = new Date()\n");
sbJavascript.Append("var dateNow = today.getDate()\n");
sbJavascript.Append("var monthNow = today.getMonth()\n");
sbJavascript.Append("var yearNow = today.getYear()\n");
sbJavascript.Append(@"var imgsrc = new Array(""" + m_drop1Gif + @""",""" + m_drop2Gif + @""",""" + m_left1Gif + @""",""" + m_left2Gif + @""",""" + m_right1Gif + @""",""" + m_right2Gif + @""")" + "\n");
sbJavascript.Append("var img = new Array()\n\n");
sbJavascript.Append("var bShow = false;\n\n");
sbJavascript.Append("/* hides <select> and <applet> objects (for IE only) */\n");
sbJavascript.Append("function hideElement( elmID, overDiv )\n");
sbJavascript.Append("{\n");
sbJavascript.Append("if( ie )\n");
sbJavascript.Append("{\n");
sbJavascript.Append("for( i = 0; i < document.all.tags( elmID ).length; i++ )\n");
sbJavascript.Append("{\n");
sbJavascript.Append("obj = document.all.tags( elmID )[i];\n");
sbJavascript.Append("if( !obj || !obj.offsetParent )\n");
sbJavascript.Append("{\n");
sbJavascript.Append("continue;\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("// Find the element's offsetTop and offsetLeft relative to the BODY tag.\n");
sbJavascript.Append("objLeft = obj.offsetLeft;\n");
sbJavascript.Append("objTop = obj.offsetTop;\n");
sbJavascript.Append("objParent = obj.offsetParent;\n\n");
sbJavascript.Append(@"while( objParent.tagName.toUpperCase() != ""BODY"" )" + "\n");
sbJavascript.Append("{\n");
sbJavascript.Append("objLeft += objParent.offsetLeft;\n");
sbJavascript.Append("objTop += objParent.offsetTop;\n");
sbJavascript.Append("objParent = objParent.offsetParent;\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("objHeight = obj.offsetHeight;\n");
sbJavascript.Append("objWidth = obj.offsetWidth;\n\n");
sbJavascript.Append("if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );\n");
sbJavascript.Append("else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );\n");
sbJavascript.Append("else if( overDiv.offsetTop >= ( objTop + objHeight ));\n");
sbJavascript.Append("else if( overDiv.offsetLeft >= ( objLeft + objWidth ));\n");
sbJavascript.Append("else\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"obj.style.visibility = ""hidden"";" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("/*\n");
sbJavascript.Append("* unhides <select> and <applet> objects (for IE only)\n");
sbJavascript.Append("*/\n");
sbJavascript.Append("function showElement( elmID )\n");
sbJavascript.Append("{\n");
sbJavascript.Append("if( ie )\n");
sbJavascript.Append("{\n");
sbJavascript.Append("for( i = 0; i < document.all.tags( elmID ).length; i++ )\n");
sbJavascript.Append("{\n");
sbJavascript.Append("obj = document.all.tags( elmID )[i];\n\n");
sbJavascript.Append("if( !obj || !obj.offsetParent )\n");
sbJavascript.Append("{\n");
sbJavascript.Append("continue;\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"obj.style.visibility = """";" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function HolidayRec (d, m, y, desc)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("this.d = d\n");
sbJavascript.Append("this.m = m\n");
sbJavascript.Append("this.y = y\n");
sbJavascript.Append("this.desc = desc\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("var HolidaysCounter = 0\n");
sbJavascript.Append("var Holidays = new Array()\n\n");
sbJavascript.Append("function addHoliday (d, m, y, desc)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("Holidays[HolidaysCounter++] = new HolidayRec ( d, m, y, desc )\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("if (dom)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("for (i=0;i<imgsrc.length;i++)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("img[i] = new Image\n");
sbJavascript.Append("img[i].src = imgDir + imgsrc[i]\n");
sbJavascript.Append("}\n");
sbJavascript.Append(@"document.write (""<div onclick='bShow=true' id='calendar' style='z-index:+999;position:absolute;visibility:hidden;'><table width=""+((showWeekNumber==1)?250:220)+"" style='font-family:arial;font-size:11px;border-width:1;border-style:solid;border-color:#a0a0a0;font-family:arial; font-size:11px}' bgcolor='#ffffff'><tr bgcolor='#0000aa'><td><table width='""+((showWeekNumber==1)?248:218)+""'><tr><td style='padding:2px;font-family:arial; font-size:11px;'><font color='#ffffff'><B><span id='caption'></span></B></font></td><td align=right><a href='javascript:hideCalendar()'><IMG SRC='""+imgDir+""" + m_closeGif + @"' WIDTH='15' HEIGHT='13' BORDER='0' ALT='Close the Calendar'></a></td></tr></table></td></tr><tr><td style='padding:5px' bgcolor=#ffffff><span id='content'></span></td></tr>"")" + "\n\n");
sbJavascript.Append("if (showToday==1)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"document.write (""<tr bgcolor=#f0f0f0><td style='padding:5px' align=center><span id='lblToday'></span></td></tr>"")" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"document.write (""</table></div><div id='selectMonth' style='z-index:+999;position:absolute;visibility:hidden;'></div><div id='selectYear' style='z-index:+999;position:absolute;visibility:hidden;'></div>"");" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"var monthName = new Array(""January"",""February"",""March"",""April"",""May"",""June"",""July"",""August"",""September"",""October"",""November"",""December"")" + "\n");
sbJavascript.Append("if (startAt==0)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"dayName = new Array (""Sun"",""Mon"",""Tue"",""Wed"",""Thu"",""Fri"",""Sat"")" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append("else\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"dayName = new Array (""Mon"",""Tue"",""Wed"",""Thu"",""Fri"",""Sat"",""Sun"")" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append(@"var styleAnchor=""text-decoration:none;color:black;""" + "\n");
sbJavascript.Append(@"var styleLightBorder=""border-style:solid;border-width:1px;border-color:#a0a0a0;""" + "\n\n");
sbJavascript.Append("function swapImage(srcImg, destImg){\n");
sbJavascript.Append(@"if (ie) { document.getElementById(srcImg).setAttribute(""src"",imgDir + destImg) }" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function init() {\n");
sbJavascript.Append("if (!ns4)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("if (!ie) { yearNow += 1900 }\n\n");
sbJavascript.Append(@"crossobj=(dom)?document.getElementById(""calendar"").style : ie? document.all.calendar : document.calendar" + "\n");
sbJavascript.Append("hideCalendar()\n\n");
sbJavascript.Append(@"crossMonthObj=(dom)?document.getElementById(""selectMonth"").style : ie? document.all.selectMonth : document.selectMonth" + "\n\n");
sbJavascript.Append(@"crossYearObj=(dom)?document.getElementById(""selectYear"").style : ie? document.all.selectYear : document.selectYear" + "\n\n");
sbJavascript.Append("monthConstructed=false;\n");
sbJavascript.Append("yearConstructed=false;\n\n");
sbJavascript.Append("if (showToday==1)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"document.getElementById(""lblToday"").innerHTML = todayString + "" <a onmousemove='window.status=\""""+gotoString+""\""' onmouseout='window.status=\""\""' title='""+gotoString+""' style='""+styleAnchor+""' href='javascript:monthSelected=monthNow;yearSelected=yearNow;constructCalendar();'>""+dayName[(today.getDay()-startAt==-1)?6:(today.getDay()-startAt)]+"", "" + dateNow + "" "" + monthName[monthNow].substring(0,3) + "" "" + yearNow + ""</a>""" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"sHTML1=""<span id='spanLeft' style='border-style:solid;border-width:1;border-color:#3366FF;cursor:pointer' onmouseover='swapImage(\""changeLeft\"",\""left2.gif\"");this.style.borderColor=\""#88AAFF\"";window.status=\""""+scrollLeftMessage+""\""' onclick='javascript:decMonth()' onmouseout='clearInterval(intervalID1);swapImage(\""changeLeft\"",\""left1.gif\"");this.style.borderColor=\""#3366FF\"";window.status=\""\""' onmousedown='clearTimeout(timeoutID1);timeoutID1=setTimeout(\""StartDecMonth()\"",500)' onmouseup='clearTimeout(timeoutID1);clearInterval(intervalID1)'> <IMG id='changeLeft' SRC='""+imgDir+""left1.gif' width=10 height=11 BORDER=0> </span> """ + "\n");
sbJavascript.Append(@"sHTML1+=""<span id='spanRight' style='border-style:solid;border-width:1;border-color:#3366FF;cursor:pointer' onmouseover='swapImage(\""changeRight\"",\""right2.gif\"");this.style.borderColor=\""#88AAFF\"";window.status=\""""+scrollRightMessage+""\""' onmouseout='clearInterval(intervalID1);swapImage(\""changeRight\"",\""right1.gif\"");this.style.borderColor=\""#3366FF\"";window.status=\""\""' onclick='incMonth()' onmousedown='clearTimeout(timeoutID1);timeoutID1=setTimeout(\""StartIncMonth()\"",500)' onmouseup='clearTimeout(timeoutID1);clearInterval(intervalID1)'> <IMG id='changeRight' SRC='""+imgDir+""right1.gif' width=10 height=11 BORDER=0> </span> """ + "\n");
sbJavascript.Append(@"sHTML1+=""<span id='spanMonth' style='border-style:solid;border-width:1;border-color:#3366FF;cursor:pointer' onmouseover='swapImage(\""changeMonth\"",\""drop2.gif\"");this.style.borderColor=\""#88AAFF\"";window.status=\""""+selectMonthMessage+""\""' onmouseout='swapImage(\""changeMonth\"",\""drop1.gif\"");this.style.borderColor=\""#3366FF\"";window.status=\""\""' onclick='popUpMonth()'></span> """ + "\n");
sbJavascript.Append(@"sHTML1+=""<span id='spanYear' style='border-style:solid;border-width:1;border-color:#3366FF;cursor:pointer' onmouseover='swapImage(\""changeYear\"",\""drop2.gif\"");this.style.borderColor=\""#88AAFF\"";window.status=\""""+selectYearMessage+""\""' onmouseout='swapImage(\""changeYear\"",\""drop1.gif\"");this.style.borderColor=\""#3366FF\"";window.status=\""\""' onclick='popUpYear()'></span> """ + "\n\n");
sbJavascript.Append(@"document.getElementById(""caption"").innerHTML = sHTML1" + "\n\n");
sbJavascript.Append("bPageLoaded=true\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function hideCalendar() {\n");
sbJavascript.Append(@"crossobj.visibility=""hidden""" + "\n");
sbJavascript.Append(@"if (crossMonthObj != null){crossMonthObj.visibility=""hidden""}" + "\n");
sbJavascript.Append(@"if (crossYearObj != null){crossYearObj.visibility=""hidden""}" + "\n\n");
sbJavascript.Append("showElement( 'SELECT' );\n");
sbJavascript.Append("showElement( 'APPLET' );\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function padZero(num) {\n");
sbJavascript.Append("return (num < 10)? '0' + num : num ;\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function constructDate(d,m,y)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("sTmp = dateFormat\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""dd"",""<e>"")" + "\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""d"",""<d>"")" + "\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""<e>"",padZero(d))" + "\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""<d>"",d)" + "\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""mmm"",""<o>"")" + "\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""mm"",""<n>"")" + "\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""m"",""<m>"")" + "\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""<m>"",m+1)" + "\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""<n>"",padZero(m+1))" + "\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""<o>"",monthName[m])" + "\n");
sbJavascript.Append(@"return sTmp.replace (""yyyy"",y)" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function closeCalendar() {\n");
sbJavascript.Append("var sTmp\n\n");
sbJavascript.Append("hideCalendar();\n");
sbJavascript.Append("ctlToPlaceValue.value = constructDate(dateSelected,monthSelected,yearSelected)\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("/*** Month Pulldown ***/\n\n");
sbJavascript.Append("function StartDecMonth()\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"intervalID1=setInterval(""decMonth()"",80)" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function StartIncMonth()\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"intervalID1=setInterval(""incMonth()"",80)" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function incMonth () {\n");
sbJavascript.Append("monthSelected++\n");
sbJavascript.Append("if (monthSelected>11) {\n");
sbJavascript.Append("monthSelected=0\n");
sbJavascript.Append("yearSelected++\n");
sbJavascript.Append("}\n");
sbJavascript.Append("constructCalendar()\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function decMonth () {\n");
sbJavascript.Append("monthSelected--\n");
sbJavascript.Append("if (monthSelected<0) {\n");
sbJavascript.Append("monthSelected=11\n");
sbJavascript.Append("yearSelected--\n");
sbJavascript.Append("}\n");
sbJavascript.Append("constructCalendar()\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function constructMonth() {\n");
sbJavascript.Append("popDownYear()\n");
sbJavascript.Append("if (!monthConstructed) {\n");
sbJavascript.Append(@"sHTML = """"" + "\n");
sbJavascript.Append("for (i=0; i<12; i++) {\n");
sbJavascript.Append("sName = monthName[i];\n");
sbJavascript.Append("if (i==monthSelected){\n");
sbJavascript.Append(@"sName = ""<B>"" + sName + ""</B>""" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append(@"sHTML += ""<tr><td id='m"" + i + ""' onmouseover='this.style.backgroundColor=\""#353aff\""' onmouseout='this.style.backgroundColor=\""\""' style='cursor:pointer' onclick='monthConstructed=false;monthSelected="" + i + "";constructCalendar();popDownMonth();event.cancelBubble=true'> "" + sName + "" </td></tr>""" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"document.getElementById(""selectMonth"").innerHTML = ""<table width=70 style='font-family:arial; font-size:11px; border-width:1; border-style:solid; border-color:#a0a0a0;' bgcolor='#3366ff' cellspacing=0 onmouseover='clearTimeout(timeoutID1)' onmouseout='clearTimeout(timeoutID1);timeoutID1=setTimeout(\""popDownMonth()\"",100);event.cancelBubble=true'>"" + sHTML + ""</table>""" + "\n\n");
sbJavascript.Append("monthConstructed=true\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function popUpMonth() {\n");
sbJavascript.Append("constructMonth()\n");
sbJavascript.Append(@"crossMonthObj.visibility = (dom||ie)? ""visible"" : ""show""" + "\n");
sbJavascript.Append("crossMonthObj.left = parseInt(crossobj.left) + 50\n");
sbJavascript.Append("crossMonthObj.top = parseInt(crossobj.top) + 26\n\n");
sbJavascript.Append(@"hideElement( 'SELECT', document.getElementById(""selectMonth"") );" + "\n");
sbJavascript.Append(@"hideElement( 'APPLET', document.getElementById(""selectMonth"") );" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function popDownMonth() {\n");
sbJavascript.Append(@"crossMonthObj.visibility= ""hidden""" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("/*** Year Pulldown ***/\n\n");
sbJavascript.Append("function incYear() {\n");
sbJavascript.Append("for (i=0; i<7; i++){\n");
sbJavascript.Append("newYear = (i+nStartingYear)+1\n");
sbJavascript.Append("if (newYear==yearSelected)\n");
sbJavascript.Append(@"{ txtYear = "" <B>"" + newYear + ""</B> "" }" + "\n");
sbJavascript.Append("else\n");
sbJavascript.Append(@"{ txtYear = "" "" + newYear + "" "" }" + "\n");
sbJavascript.Append(@"document.getElementById(""y""+i).innerHTML = txtYear" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append("nStartingYear ++;\n");
sbJavascript.Append("bShow=true\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function decYear() {\n");
sbJavascript.Append("for (i=0; i<7; i++){\n");
sbJavascript.Append("newYear = (i+nStartingYear)-1\n");
sbJavascript.Append("if (newYear==yearSelected)\n");
sbJavascript.Append(@"{ txtYear = "" <B>"" + newYear + ""</B> "" }" + "\n");
sbJavascript.Append("else\n");
sbJavascript.Append(@"{ txtYear = "" "" + newYear + "" "" }" + "\n");
sbJavascript.Append(@"document.getElementById(""y""+i).innerHTML = txtYear" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append("nStartingYear --;\n");
sbJavascript.Append("bShow=true\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function selectYear(nYear) {\n");
sbJavascript.Append("yearSelected=parseInt(nYear+nStartingYear);\n");
sbJavascript.Append("yearConstructed=false;\n");
sbJavascript.Append("constructCalendar();\n");
sbJavascript.Append("popDownYear();\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function constructYear() {\n");
sbJavascript.Append("popDownMonth()\n");
sbJavascript.Append(@"sHTML = """"" + "\n");
sbJavascript.Append("if (!yearConstructed) {\n\n");
sbJavascript.Append(@"sHTML = ""<tr><td align='center' onmouseover='this.style.backgroundColor=\""#353aff\""' onmouseout='clearInterval(intervalID1);this.style.backgroundColor=\""\""' style='cursor:pointer' onmousedown='clearInterval(intervalID1);intervalID1=setInterval(\""decYear()\"",30)' onmouseup='clearInterval(intervalID1)'>-</td></tr>""" + "\n\n");
sbJavascript.Append("j = 0\n");
sbJavascript.Append("nStartingYear = yearSelected-3\n");
sbJavascript.Append("for (i=(yearSelected-3); i<=(yearSelected+3); i++) {\n");
sbJavascript.Append("sName = i;\n");
sbJavascript.Append("if (i==yearSelected){\n");
sbJavascript.Append(@"sName = ""<B>"" + sName + ""</B>""" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"sHTML += ""<tr><td id='y"" + j + ""' onmouseover='this.style.backgroundColor=\""#353aff\""' onmouseout='this.style.backgroundColor=\""\""' style='cursor:pointer' onclick='selectYear(""+j+"");event.cancelBubble=true'> "" + sName + "" </td></tr>""" + "\n");
sbJavascript.Append("j ++;\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"sHTML += ""<tr><td align='center' onmouseover='this.style.backgroundColor=\""#353aff\""' onmouseout='clearInterval(intervalID2);this.style.backgroundColor=\""\""' style='cursor:pointer' onmousedown='clearInterval(intervalID2);intervalID2=setInterval(\""incYear()\"",30)' onmouseup='clearInterval(intervalID2)'>+</td></tr>""" + "\n\n");
sbJavascript.Append(@"document.getElementById(""selectYear"").innerHTML = ""<table width=44 style='font-family:arial; font-size:11px; border-width:1; border-style:solid; border-color:#a0a0a0;' bgcolor='#3366ff' onmouseover='clearTimeout(timeoutID2)' onmouseout='clearTimeout(timeoutID2);timeoutID2=setTimeout(\""popDownYear()\"",100)' cellspacing=0>"" + sHTML + ""</table>""" + "\n\n");
sbJavascript.Append("yearConstructed = true\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("function popDownYear() {\n");
sbJavascript.Append("clearInterval(intervalID1)\n");
sbJavascript.Append("clearTimeout(timeoutID1)\n");
sbJavascript.Append("clearInterval(intervalID2)\n");
sbJavascript.Append("clearTimeout(timeoutID2)\n");
sbJavascript.Append(@"crossYearObj.visibility= ""hidden""" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function popUpYear() {\n");
sbJavascript.Append("var leftOffset\n\n");
sbJavascript.Append("constructYear()\n");
sbJavascript.Append(@"crossYearObj.visibility = (dom||ie)? ""visible"" : ""show""" + "\n");
sbJavascript.Append(@"leftOffset = parseInt(crossobj.left) + document.getElementById(""spanYear"").offsetLeft" + "\n");
sbJavascript.Append("if (ie)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("leftOffset += 6\n");
sbJavascript.Append("}\n");
sbJavascript.Append("crossYearObj.left = leftOffset\n");
sbJavascript.Append("crossYearObj.top = parseInt(crossobj.top) + 26\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("/*** calendar ***/\n");
sbJavascript.Append("function WeekNbr(n) {\n");
sbJavascript.Append("// Algorithm used:\n");
sbJavascript.Append("// From Klaus Tondering's Calendar document (The Authority/Guru)\n");
sbJavascript.Append("// hhtp://www.tondering.dk/claus/calendar.html\n");
sbJavascript.Append("// a = (14-month) / 12\n");
sbJavascript.Append("// y = year + 4800 - a\n");
sbJavascript.Append("// m = month + 12a - 3\n");
sbJavascript.Append("// J = day + (153m + 2) / 5 + 365y + y / 4 - y / 100 + y / 400 - 32045\n");
sbJavascript.Append("// d4 = (J + 31741 - (J mod 7)) mod 146097 mod 36524 mod 1461\n");
sbJavascript.Append("// L = d4 / 1460\n");
sbJavascript.Append("// d1 = ((d4 - L) mod 365) + L\n");
sbJavascript.Append("// WeekNumber = d1 / 7 + 1\n\n");
sbJavascript.Append("year = n.getFullYear();\n");
sbJavascript.Append("month = n.getMonth() + 1;\n");
sbJavascript.Append("if (startAt == 0) {\n");
sbJavascript.Append("day = n.getDate() + 1;\n");
sbJavascript.Append("}\n");
sbJavascript.Append("else {\n");
sbJavascript.Append("day = n.getDate();\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("a = Math.floor((14-month) / 12);\n");
sbJavascript.Append("y = year + 4800 - a;\n");
sbJavascript.Append("m = month + 12 * a - 3;\n");
sbJavascript.Append("b = Math.floor(y/4) - Math.floor(y/100) + Math.floor(y/400);\n");
sbJavascript.Append("J = day + Math.floor((153 * m + 2) / 5) + 365 * y + b - 32045;\n");
sbJavascript.Append("d4 = (((J + 31741 - (J % 7)) % 146097) % 36524) % 1461;\n");
sbJavascript.Append("L = Math.floor(d4 / 1460);\n");
sbJavascript.Append("d1 = ((d4 - L) % 365) + L;\n");
sbJavascript.Append("week = Math.floor(d1/7) + 1;\n\n");
sbJavascript.Append("return week;\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function constructCalendar () {\n");
sbJavascript.Append("var aNumDays = Array (31,0,31,30,31,30,31,31,30,31,30,31)\n\n");
sbJavascript.Append("var dateMessage\n");
sbJavascript.Append("var startDate = new Date (yearSelected,monthSelected,1)\n");
sbJavascript.Append("var endDate\n\n");
sbJavascript.Append("if (monthSelected==1)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("endDate = new Date (yearSelected,monthSelected+1,1);\n");
sbJavascript.Append("endDate = new Date (endDate - (24*60*60*1000));\n");
sbJavascript.Append("numDaysInMonth = endDate.getDate()\n");
sbJavascript.Append("}\n");
sbJavascript.Append("else\n");
sbJavascript.Append("{\n");
sbJavascript.Append("numDaysInMonth = aNumDays[monthSelected];\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("datePointer = 0\n");
sbJavascript.Append("dayPointer = startDate.getDay() - startAt\n\n");
sbJavascript.Append("if (dayPointer<0)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("dayPointer = 6\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"sHTML = ""<table border=0 style='font-family:verdana;font-size:10px;'><tr>""" + "\n\n");
sbJavascript.Append("if (showWeekNumber==1)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"sHTML += ""<td width=27><b>"" + weekString + ""</b></td><td width=1 rowspan=7 bgcolor='#d0d0d0' style='padding:0px'><img src='""+imgDir+""" + m_dividerGif + @"' width=1></td>""" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("for (i=0; i<7; i++) {\n");
sbJavascript.Append(@"sHTML += ""<td width='27' align='right'><B>""+ dayName[i]+""</B></td>""" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append(@"sHTML +=""</tr><tr>""" + "\n\n");
sbJavascript.Append("if (showWeekNumber==1)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"sHTML += ""<td align=right>"" + WeekNbr(startDate) + "" </td>""" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("for ( var i=1; i<=dayPointer;i++ )\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"sHTML += ""<td> </td>""" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("for ( datePointer=1; datePointer<=numDaysInMonth; datePointer++ )\n");
sbJavascript.Append("{\n");
sbJavascript.Append("dayPointer++;\n");
sbJavascript.Append(@"sHTML += ""<td align=right>""" + "\n");
sbJavascript.Append("sStyle=styleAnchor\n");
sbJavascript.Append("if ((datePointer==odateSelected) && (monthSelected==omonthSelected) && (yearSelected==oyearSelected))\n");
sbJavascript.Append("{ sStyle+=styleLightBorder }\n\n");
sbJavascript.Append(@"sHint = """"" + "\n");
sbJavascript.Append("for (k=0;k<HolidaysCounter;k++)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("if ((parseInt(Holidays[k].d)==datePointer)&&(parseInt(Holidays[k].m)==(monthSelected+1)))\n");
sbJavascript.Append("{\n");
sbJavascript.Append("if ((parseInt(Holidays[k].y)==0)||((parseInt(Holidays[k].y)==yearSelected)&&(parseInt(Holidays[k].y)!=0)))\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"sStyle+=""background-color:#FFDDDD;""" + "\n");
sbJavascript.Append(@"sHint+=sHint==""""?Holidays[k].desc:""\n""+Holidays[k].desc" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"var regexp= /\""/g" + "\n");
sbJavascript.Append(@"sHint=sHint.replace(regexp,""""")" + "\n\n");
sbJavascript.Append(@"dateMessage = ""onmousemove='window.status=\""""+selectDateMessage.replace(""[date]"",constructDate(datePointer,monthSelected,yearSelected))+""\""' onmouseout='window.status=\""\""' """ + "\n\n");
sbJavascript.Append("if ((datePointer==dateNow)&&(monthSelected==monthNow)&&(yearSelected==yearNow))\n");
sbJavascript.Append(@"{ sHTML += ""<b><a ""+dateMessage+"" title=\"""" + sHint + ""\"" style='""+sStyle+""' href='javascript:dateSelected=""+datePointer+"";closeCalendar();'><font color=#ff0000> "" + datePointer + ""</font> </a></b>""}" + "\n");
sbJavascript.Append("else if (dayPointer % 7 == (startAt * -1)+1)\n");
sbJavascript.Append(@"{ sHTML += ""<a ""+dateMessage+"" title=\"""" + sHint + ""\"" style='""+sStyle+""' href='javascript:dateSelected=""+datePointer + "";closeCalendar();'> <font color=#909090>"" + datePointer + ""</font> </a>"" }" + "\n");
sbJavascript.Append("else\n");
sbJavascript.Append(@"{ sHTML += ""<a ""+dateMessage+"" title=\"""" + sHint + ""\"" style='""+sStyle+""' href='javascript:dateSelected=""+datePointer + "";closeCalendar();'> "" + datePointer + "" </a>"" }" + "\n\n");
sbJavascript.Append(@"sHTML += """"" + "\n");
sbJavascript.Append("if ((dayPointer+startAt) % 7 == startAt) {\n");
sbJavascript.Append(@"sHTML += ""</tr><tr>""" + "\n");
sbJavascript.Append("if ((showWeekNumber==1)&&(datePointer<numDaysInMonth))\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"sHTML += ""<td align=right>"" + (WeekNbr(new Date(yearSelected,monthSelected,datePointer+1))) + "" </td>""" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"document.getElementById(""content"").innerHTML = sHTML" + "\n");
sbJavascript.Append(@"document.getElementById(""spanMonth"").innerHTML = "" "" + monthName[monthSelected] + "" <IMG id='changeMonth' SRC='""+imgDir+""drop1.gif' WIDTH='12' HEIGHT='10' BORDER=0>""" + "\n");
sbJavascript.Append(@"document.getElementById(""spanYear"").innerHTML = "" "" + yearSelected + "" <IMG id='changeYear' SRC='""+imgDir+""drop1.gif' WIDTH='12' HEIGHT='10' BORDER=0>""" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function popUpCalendar(ctl, ctl2, format) {\n");
sbJavascript.Append("var leftpos=0\n");
sbJavascript.Append("var toppos=0\n\n");
sbJavascript.Append("if (bPageLoaded)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"if ( crossobj.visibility == ""hidden"" ) {" + "\n");
sbJavascript.Append("ctlToPlaceValue = ctl2\n");
sbJavascript.Append("dateFormat=format;\n\n");
sbJavascript.Append(@"formatChar = "" """ + "\n");
sbJavascript.Append("aFormat = dateFormat.split(formatChar)\n");
sbJavascript.Append("if (aFormat.length<3)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"formatChar = ""/""" + "\n");
sbJavascript.Append("aFormat = dateFormat.split(formatChar)\n");
sbJavascript.Append("if (aFormat.length<3)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"formatChar = "".""" + "\n");
sbJavascript.Append("aFormat = dateFormat.split(formatChar)\n");
sbJavascript.Append("if (aFormat.length<3)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"formatChar = ""-""" + "\n");
sbJavascript.Append("aFormat = dateFormat.split(formatChar)\n");
sbJavascript.Append("if (aFormat.length<3)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("// invalid date format\n");
sbJavascript.Append(@"formatChar=""""" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("tokensChanged = 0\n");
sbJavascript.Append(@"if ( formatChar != """" )" + "\n");
sbJavascript.Append("{\n");
sbJavascript.Append("// use user's date\n");
sbJavascript.Append("aData = ctl2.value.split(formatChar)\n\n");
sbJavascript.Append("for (i=0;i<3;i++)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"if ((aFormat[i]==""d"") || (aFormat[i]==""dd""))" + "\n");
sbJavascript.Append("{\n");
sbJavascript.Append("dateSelected = parseInt(aData[i], 10)\n");
sbJavascript.Append("tokensChanged ++\n");
sbJavascript.Append("}\n");
sbJavascript.Append(@"else if ((aFormat[i]==""m"") || (aFormat[i]==""mm""))" + "\n");
sbJavascript.Append("{\n");
sbJavascript.Append("monthSelected = parseInt(aData[i], 10) - 1\n");
sbJavascript.Append("tokensChanged ++\n");
sbJavascript.Append("}\n");
sbJavascript.Append(@"else if (aFormat[i]==""yyyy"")" + "\n");
sbJavascript.Append("{\n");
sbJavascript.Append("yearSelected = parseInt(aData[i], 10)\n");
sbJavascript.Append("tokensChanged ++\n");
sbJavascript.Append("}\n");
sbJavascript.Append(@"else if (aFormat[i]==""mmm"")" + "\n");
sbJavascript.Append("{\n");
sbJavascript.Append("for (j=0; j<12; j++)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("if (aData[i]==monthName[j])\n");
sbJavascript.Append("{\n");
sbJavascript.Append("monthSelected=j\n");
sbJavascript.Append("tokensChanged ++\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("if ((tokensChanged!=3)||isNaN(dateSelected)||isNaN(monthSelected)||isNaN(yearSelected))\n");
sbJavascript.Append("{\n");
sbJavascript.Append("dateSelected = dateNow\n");
sbJavascript.Append("monthSelected = monthNow\n");
sbJavascript.Append("yearSelected = yearNow\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("odateSelected=dateSelected\n");
sbJavascript.Append("omonthSelected=monthSelected\n");
sbJavascript.Append("oyearSelected=yearSelected\n\n");
sbJavascript.Append("aTag = ctl\n");
sbJavascript.Append("do {\n");
sbJavascript.Append("aTag = aTag.offsetParent;\n");
sbJavascript.Append("leftpos += aTag.offsetLeft;\n");
sbJavascript.Append("toppos += aTag.offsetTop;\n");
sbJavascript.Append(@"} while(aTag.tagName!=""BODY"");" + "\n\n");
sbJavascript.Append("crossobj.left = fixedX==-1 ? ctl.offsetLeft + leftpos : fixedX\n");
sbJavascript.Append("crossobj.top = fixedY==-1 ? ctl.offsetTop + toppos + ctl.offsetHeight + 2 : fixedY\n");
sbJavascript.Append("constructCalendar (1, monthSelected, yearSelected);\n");
sbJavascript.Append(@"crossobj.visibility=(dom||ie)? ""visible"" : ""show""" + "\n\n");
sbJavascript.Append(@"hideElement( 'SELECT', document.getElementById(""calendar"") );" + "\n");
sbJavascript.Append(@"hideElement( 'APPLET', document.getElementById(""calendar"") );" + "\n\n");
sbJavascript.Append("bShow = true;\n");
sbJavascript.Append("}\n");
sbJavascript.Append("else\n");
sbJavascript.Append("{\n");
sbJavascript.Append("hideCalendar()\n");
sbJavascript.Append("if (ctlNow!=ctl) {popUpCalendar(ctl, ctl2, format)}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("ctlNow = ctl\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("document.onkeypress = function hidecal1 () {\n");
sbJavascript.Append("if (event.keyCode==27)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("hideCalendar()\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("document.onclick = function hidecal2 () {\n");
sbJavascript.Append("if (!bShow)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("hideCalendar()\n");
sbJavascript.Append("}\n");
sbJavascript.Append("bShow = false\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("if(ie)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("init()\n");
sbJavascript.Append("}\n");
sbJavascript.Append("else\n");
sbJavascript.Append("{\n");
sbJavascript.Append("window.onload=init;\n");
sbJavascript.Append("}\n");
sbJavascript.Append("<");
sbJavascript.Append("/");
sbJavascript.Append("script>");
Page.Response.Write(sbJavascript.ToString());
}
protected override void Render(HtmlTextWriter writer)
{
placeJavascript();
writer.Write(@"<input type=""textbox"" name="""+this.ClientID+@"_DatePicker"" value="""+m_text+@""" id="""+this.ClientID+@"_DatePicker"" class="""+m_Css+@""" readonly=""readonly"" onclick=""popUpCalendar(document.all." + this.ClientID + "_DatePicker, document.all." + this.ClientID + "_DatePicker, '" + m_DateType + @"');"" />");
}
#endregion
}
}
|
|
|
|
|
Sorry that one has a bug too, try this...
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Collections.Specialized;
using System.Text;
namespace EblocControls
{
///
/// Summary description for WebCustomControl1.
///
[DefaultProperty("Text"),
ToolboxData("<{0}:WebCustomControl1 runat=server>")]
public class DatePicker : WebControl, INamingContainer,IPostBackDataHandler
{
#region Private Properties
private string m_closeGif = "close.gif";
private string m_dividerGif = "divider.gif";
private string m_drop1Gif = "drop1.gif";
private string m_drop2Gif = "drop2.gif";
private string m_left1Gif = "left1.gif";
private string m_left2Gif = "left2.gif";
private string m_right1Gif = "right1.gif";
private string m_right2Gif = "right2.gif";
private string m_imgDirectory = "/img/";
private string m_ControlCssClass = "";
private string m_text = "";
private string m_Css = "";
private string m_DateType = "dd mmm yyyy";
#endregion
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Page.RegisterRequiresPostBack(this);
}
#region Public Properties
public string Text
{
get
{
return m_text;
}
set
{
m_text = value;
}
}
public virtual bool LoadPostData(string postDataKey, NameValueCollection values)
{
try
{
m_text = values[UniqueID + "_DatePicker"].ToString();
}
catch (Exception)
{
m_text ="";
}
return false;
}
public virtual void RaisePostDataChangedEvent()
{
}
public override string CssClass
{
get
{
return m_Css;
}
set
{
m_Css = value;
}
}
public string imgClose
{
get {return m_closeGif;}
set {m_closeGif = value;}
}
public string imgDivider
{
get {return m_dividerGif;}
set {m_dividerGif = value;}
}
public string imgDrop1
{
get {return m_drop1Gif;}
set {m_drop1Gif = value;}
}
public string imgDrop2
{
get {return m_drop2Gif;}
set {m_drop2Gif = value;}
}
public string imgLeft1
{
get {return m_left1Gif;}
set {m_left1Gif = value;}
}
public string imgLeft2
{
get {return m_left2Gif;}
set {m_left2Gif = value;}
}
public string imgRight1
{
get {return m_right1Gif;}
set {m_right1Gif = value;}
}
public string imgDirectory
{
get {return m_imgDirectory;}
set {m_imgDirectory = value;}
}
public string ControlCssClass
{
get {return m_ControlCssClass;}
set {m_ControlCssClass = value;}
}
public string DateType
{
get {return m_DateType;}
set {m_DateType = value;}
}
#endregion
#region Constructors
public DatePicker()
{
//
// TODO: Add constructor logic here
//
}
#endregion
#region Private Methods/Properties
private void placeJavascript()
{
StringBuilder sbJavascript = new StringBuilder();
sbJavascript.Append("");
sbJavascript.Append("// written by Tan Ling Wee on 2 Dec 2001\n");
sbJavascript.Append("// last updated 23 June 2002\n");
sbJavascript.Append("// email : fuushikaden@yahoo.com\n\n");
sbJavascript.Append("var fixedX = -1 // x position (-1 if to appear below control)\n");
sbJavascript.Append("var fixedY = -1 // y position (-1 if to appear below control)\n");
sbJavascript.Append("var startAt = 1 // 0 - sunday ; 1 - monday\n");
sbJavascript.Append("var showWeekNumber = 1 // 0 - don't show; 1 - show\n");
sbJavascript.Append("var showToday = 1 // 0 - don't show; 1 - show\n");
sbJavascript.Append(@"var imgDir = """ + m_imgDirectory + @"""" + "\n");
sbJavascript.Append(@"var gotoString = ""Go To Current Month""" + "\n");
sbJavascript.Append(@"var todayString = ""Today is""" + "\n");
sbJavascript.Append(@"var weekString = ""Wk""" + "\n");
sbJavascript.Append(@"var scrollLeftMessage = ""Click to scroll to previous month. Hold mouse button to scroll automatically.""" + "\n");
sbJavascript.Append(@"var scrollRightMessage = ""Click to scroll to next month. Hold mouse button to scroll automatically.""" + "\n");
sbJavascript.Append(@"var selectMonthMessage = ""Click to select a month.""" + "\n");
sbJavascript.Append(@"var selectYearMessage = ""Click to select a year.""" + "\n");
sbJavascript.Append(@"var selectDateMessage = ""Select [date] as date."" // do not replace [date], it will be replaced by date." + "\n");
sbJavascript.Append("var crossobj, crossMonthObj, crossYearObj, monthSelected, yearSelected, dateSelected, omonthSelected, oyearSelected, odateSelected, monthConstructed, yearConstructed, intervalID1, intervalID2, timeoutID1, timeoutID2, ctlToPlaceValue, ctlNow, dateFormat, nStartingYear\n\n");
sbJavascript.Append("var bPageLoaded=false\n");
sbJavascript.Append("var ie=document.all\n");
sbJavascript.Append("var dom=document.getElementById\n\n");
sbJavascript.Append("var ns4=document.layers\n");
sbJavascript.Append("var today = new Date()\n");
sbJavascript.Append("var dateNow = today.getDate()\n");
sbJavascript.Append("var monthNow = today.getMonth()\n");
sbJavascript.Append("var yearNow = today.getYear()\n");
sbJavascript.Append(@"var imgsrc = new Array(""" + m_drop1Gif + @""",""" + m_drop2Gif + @""",""" + m_left1Gif + @""",""" + m_left2Gif + @""",""" + m_right1Gif + @""",""" + m_right2Gif + @""")" + "\n");
sbJavascript.Append("var img = new Array()\n\n");
sbJavascript.Append("var bShow = false;\n\n");
sbJavascript.Append("/* hides <select> and <applet> objects (for IE only) */\n");
sbJavascript.Append("function hideElement( elmID, overDiv )\n");
sbJavascript.Append("{\n");
sbJavascript.Append("if( ie )\n");
sbJavascript.Append("{\n");
sbJavascript.Append("for( i = 0; i < document.all.tags( elmID ).length; i++ )\n");
sbJavascript.Append("{\n");
sbJavascript.Append("obj = document.all.tags( elmID )[i];\n");
sbJavascript.Append("if( !obj || !obj.offsetParent )\n");
sbJavascript.Append("{\n");
sbJavascript.Append("continue;\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("// Find the element's offsetTop and offsetLeft relative to the BODY tag.\n");
sbJavascript.Append("objLeft = obj.offsetLeft;\n");
sbJavascript.Append("objTop = obj.offsetTop;\n");
sbJavascript.Append("objParent = obj.offsetParent;\n\n");
sbJavascript.Append(@"while( objParent.tagName.toUpperCase() != ""BODY"" )" + "\n");
sbJavascript.Append("{\n");
sbJavascript.Append("objLeft += objParent.offsetLeft;\n");
sbJavascript.Append("objTop += objParent.offsetTop;\n");
sbJavascript.Append("objParent = objParent.offsetParent;\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("objHeight = obj.offsetHeight;\n");
sbJavascript.Append("objWidth = obj.offsetWidth;\n\n");
sbJavascript.Append("if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );\n");
sbJavascript.Append("else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );\n");
sbJavascript.Append("else if( overDiv.offsetTop >= ( objTop + objHeight ));\n");
sbJavascript.Append("else if( overDiv.offsetLeft >= ( objLeft + objWidth ));\n");
sbJavascript.Append("else\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"obj.style.visibility = ""hidden"";" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("/*\n");
sbJavascript.Append("* unhides <select> and <applet> objects (for IE only)\n");
sbJavascript.Append("*/\n");
sbJavascript.Append("function showElement( elmID )\n");
sbJavascript.Append("{\n");
sbJavascript.Append("if( ie )\n");
sbJavascript.Append("{\n");
sbJavascript.Append("for( i = 0; i < document.all.tags( elmID ).length; i++ )\n");
sbJavascript.Append("{\n");
sbJavascript.Append("obj = document.all.tags( elmID )[i];\n\n");
sbJavascript.Append("if( !obj || !obj.offsetParent )\n");
sbJavascript.Append("{\n");
sbJavascript.Append("continue;\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"obj.style.visibility = """";" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function HolidayRec (d, m, y, desc)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("this.d = d\n");
sbJavascript.Append("this.m = m\n");
sbJavascript.Append("this.y = y\n");
sbJavascript.Append("this.desc = desc\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("var HolidaysCounter = 0\n");
sbJavascript.Append("var Holidays = new Array()\n\n");
sbJavascript.Append("function addHoliday (d, m, y, desc)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("Holidays[HolidaysCounter++] = new HolidayRec ( d, m, y, desc )\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("if (dom)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("for (i=0;i<imgsrc.length;i++)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("img[i] = new Image\n");
sbJavascript.Append("img[i].src = imgDir + imgsrc[i]\n");
sbJavascript.Append("}\n");
sbJavascript.Append(@"document.write (""<div onclick='bShow=true' id='calendar' style='z-index:+999;position:absolute;visibility:hidden;'><table width=""+((showWeekNumber==1)?250:220)+"" style='font-family:arial;font-size:11px;border-width:1;border-style:solid;border-color:#a0a0a0;font-family:arial; font-size:11px}' bgcolor='#ffffff'><tr bgcolor='#0000aa'><td><table width='""+((showWeekNumber==1)?248:218)+""'><tr><td style='padding:2px;font-family:arial; font-size:11px;'><font color='#ffffff'><B><span id='caption'></span></B></font></td><td align=right><a href='javascript:hideCalendar()'><IMG SRC='""+imgDir+""" + m_closeGif + @"' WIDTH='15' HEIGHT='13' BORDER='0' ALT='Close the Calendar'></a></td></tr></table></td></tr><tr><td style='padding:5px' bgcolor=#ffffff><span id='content'></span></td></tr>"")" + "\n\n");
sbJavascript.Append("if (showToday==1)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"document.write (""<tr bgcolor=#f0f0f0><td style='padding:5px' align=center><span id='lblToday'></span></td></tr>"")" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"document.write (""</table></div><div id='selectMonth' style='z-index:+999;position:absolute;visibility:hidden;'></div><div id='selectYear' style='z-index:+999;position:absolute;visibility:hidden;'></div>"");" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"var monthName = new Array(""January"",""February"",""March"",""April"",""May"",""June"",""July"",""August"",""September"",""October"",""November"",""December"")" + "\n");
sbJavascript.Append("if (startAt==0)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"dayName = new Array (""Sun"",""Mon"",""Tue"",""Wed"",""Thu"",""Fri"",""Sat"")" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append("else\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"dayName = new Array (""Mon"",""Tue"",""Wed"",""Thu"",""Fri"",""Sat"",""Sun"")" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append(@"var styleAnchor=""text-decoration:none;color:black;""" + "\n");
sbJavascript.Append(@"var styleLightBorder=""border-style:solid;border-width:1px;border-color:#a0a0a0;""" + "\n\n");
sbJavascript.Append("function swapImage(srcImg, destImg){\n");
sbJavascript.Append(@"if (ie) { document.getElementById(srcImg).setAttribute(""src"",imgDir + destImg) }" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function init() {\n");
sbJavascript.Append("if (!ns4)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("if (!ie) { yearNow += 1900 }\n\n");
sbJavascript.Append(@"crossobj=(dom)?document.getElementById(""calendar"").style : ie? document.all.calendar : document.calendar" + "\n");
sbJavascript.Append("hideCalendar()\n\n");
sbJavascript.Append(@"crossMonthObj=(dom)?document.getElementById(""selectMonth"").style : ie? document.all.selectMonth : document.selectMonth" + "\n\n");
sbJavascript.Append(@"crossYearObj=(dom)?document.getElementById(""selectYear"").style : ie? document.all.selectYear : document.selectYear" + "\n\n");
sbJavascript.Append("monthConstructed=false;\n");
sbJavascript.Append("yearConstructed=false;\n\n");
sbJavascript.Append("if (showToday==1)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"document.getElementById(""lblToday"").innerHTML = todayString + "" <a onmousemove='window.status=\""""+gotoString+""\""' onmouseout='window.status=\""\""' title='""+gotoString+""' style='""+styleAnchor+""' href='javascript:monthSelected=monthNow;yearSelected=yearNow;constructCalendar();'>""+dayName[(today.getDay()-startAt==-1)?6:(today.getDay()-startAt)]+"", "" + dateNow + "" "" + monthName[monthNow].substring(0,3) + "" "" + yearNow + ""</a>""" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"sHTML1=""<span id='spanLeft' style='border-style:solid;border-width:1;border-color:#3366FF;cursor:pointer' onmouseover='swapImage(\""changeLeft\"",\""left2.gif\"");this.style.borderColor=\""#88AAFF\"";window.status=\""""+scrollLeftMessage+""\""' onclick='javascript:decMonth()' onmouseout='clearInterval(intervalID1);swapImage(\""changeLeft\"",\""left1.gif\"");this.style.borderColor=\""#3366FF\"";window.status=\""\""' onmousedown='clearTimeout(timeoutID1);timeoutID1=setTimeout(\""StartDecMonth()\"",500)' onmouseup='clearTimeout(timeoutID1);clearInterval(intervalID1)'> <IMG id='changeLeft' SRC='""+imgDir+""left1.gif' width=10 height=11 BORDER=0> </span> """ + "\n");
sbJavascript.Append(@"sHTML1+=""<span id='spanRight' style='border-style:solid;border-width:1;border-color:#3366FF;cursor:pointer' onmouseover='swapImage(\""changeRight\"",\""right2.gif\"");this.style.borderColor=\""#88AAFF\"";window.status=\""""+scrollRightMessage+""\""' onmouseout='clearInterval(intervalID1);swapImage(\""changeRight\"",\""right1.gif\"");this.style.borderColor=\""#3366FF\"";window.status=\""\""' onclick='incMonth()' onmousedown='clearTimeout(timeoutID1);timeoutID1=setTimeout(\""StartIncMonth()\"",500)' onmouseup='clearTimeout(timeoutID1);clearInterval(intervalID1)'> <IMG id='changeRight' SRC='""+imgDir+""right1.gif' width=10 height=11 BORDER=0> </span> """ + "\n");
sbJavascript.Append(@"sHTML1+=""<span id='spanMonth' style='border-style:solid;border-width:1;border-color:#3366FF;cursor:pointer' onmouseover='swapImage(\""changeMonth\"",\""drop2.gif\"");this.style.borderColor=\""#88AAFF\"";window.status=\""""+selectMonthMessage+""\""' onmouseout='swapImage(\""changeMonth\"",\""drop1.gif\"");this.style.borderColor=\""#3366FF\"";window.status=\""\""' onclick='popUpMonth()'></span> """ + "\n");
sbJavascript.Append(@"sHTML1+=""<span id='spanYear' style='border-style:solid;border-width:1;border-color:#3366FF;cursor:pointer' onmouseover='swapImage(\""changeYear\"",\""drop2.gif\"");this.style.borderColor=\""#88AAFF\"";window.status=\""""+selectYearMessage+""\""' onmouseout='swapImage(\""changeYear\"",\""drop1.gif\"");this.style.borderColor=\""#3366FF\"";window.status=\""\""' onclick='popUpYear()'></span> """ + "\n\n");
sbJavascript.Append(@"document.getElementById(""caption"").innerHTML = sHTML1" + "\n\n");
sbJavascript.Append("bPageLoaded=true\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function hideCalendar() {\n");
sbJavascript.Append(@"crossobj.visibility=""hidden""" + "\n");
sbJavascript.Append(@"if (crossMonthObj != null){crossMonthObj.visibility=""hidden""}" + "\n");
sbJavascript.Append(@"if (crossYearObj != null){crossYearObj.visibility=""hidden""}" + "\n\n");
sbJavascript.Append("showElement( 'SELECT' );\n");
sbJavascript.Append("showElement( 'APPLET' );\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function padZero(num) {\n");
sbJavascript.Append("return (num < 10)? '0' + num : num ;\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function constructDate(d,m,y)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("sTmp = dateFormat\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""dd"",""<e>"")" + "\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""d"",""<d>"")" + "\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""<e>"",padZero(d))" + "\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""<d>"",d)" + "\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""mmm"",""<o>"")" + "\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""mm"",""<n>"")" + "\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""m"",""<m>"")" + "\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""<m>"",m+1)" + "\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""<n>"",padZero(m+1))" + "\n");
sbJavascript.Append(@"sTmp = sTmp.replace (""<o>"",monthName[m])" + "\n");
sbJavascript.Append(@"return sTmp.replace (""yyyy"",y)" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function closeCalendar() {\n");
sbJavascript.Append("var sTmp\n\n");
sbJavascript.Append("hideCalendar();\n");
sbJavascript.Append("ctlToPlaceValue.value = constructDate(dateSelected,monthSelected,yearSelected)\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("/*** Month Pulldown ***/\n\n");
sbJavascript.Append("function StartDecMonth()\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"intervalID1=setInterval(""decMonth()"",80)" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function StartIncMonth()\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"intervalID1=setInterval(""incMonth()"",80)" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function incMonth () {\n");
sbJavascript.Append("monthSelected++\n");
sbJavascript.Append("if (monthSelected>11) {\n");
sbJavascript.Append("monthSelected=0\n");
sbJavascript.Append("yearSelected++\n");
sbJavascript.Append("}\n");
sbJavascript.Append("constructCalendar()\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function decMonth () {\n");
sbJavascript.Append("monthSelected--\n");
sbJavascript.Append("if (monthSelected<0) {\n");
sbJavascript.Append("monthSelected=11\n");
sbJavascript.Append("yearSelected--\n");
sbJavascript.Append("}\n");
sbJavascript.Append("constructCalendar()\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function constructMonth() {\n");
sbJavascript.Append("popDownYear()\n");
sbJavascript.Append("if (!monthConstructed) {\n");
sbJavascript.Append(@"sHTML = """"" + "\n");
sbJavascript.Append("for (i=0; i<12; i++) {\n");
sbJavascript.Append("sName = monthName[i];\n");
sbJavascript.Append("if (i==monthSelected){\n");
sbJavascript.Append(@"sName = ""<B>"" + sName + ""</B>""" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append(@"sHTML += ""<tr><td id='m"" + i + ""' onmouseover='this.style.backgroundColor=\""#353aff\""' onmouseout='this.style.backgroundColor=\""\""' style='cursor:pointer' onclick='monthConstructed=false;monthSelected="" + i + "";constructCalendar();popDownMonth();event.cancelBubble=true'> "" + sName + "" </td></tr>""" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"document.getElementById(""selectMonth"").innerHTML = ""<table width=70 style='font-family:arial; font-size:11px; border-width:1; border-style:solid; border-color:#a0a0a0;' bgcolor='#3366ff' cellspacing=0 onmouseover='clearTimeout(timeoutID1)' onmouseout='clearTimeout(timeoutID1);timeoutID1=setTimeout(\""popDownMonth()\"",100);event.cancelBubble=true'>"" + sHTML + ""</table>""" + "\n\n");
sbJavascript.Append("monthConstructed=true\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function popUpMonth() {\n");
sbJavascript.Append("constructMonth()\n");
sbJavascript.Append(@"crossMonthObj.visibility = (dom||ie)? ""visible"" : ""show""" + "\n");
sbJavascript.Append("crossMonthObj.left = parseInt(crossobj.left) + 50\n");
sbJavascript.Append("crossMonthObj.top = parseInt(crossobj.top) + 26\n\n");
sbJavascript.Append(@"hideElement( 'SELECT', document.getElementById(""selectMonth"") );" + "\n");
sbJavascript.Append(@"hideElement( 'APPLET', document.getElementById(""selectMonth"") );" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function popDownMonth() {\n");
sbJavascript.Append(@"crossMonthObj.visibility= ""hidden""" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("/*** Year Pulldown ***/\n\n");
sbJavascript.Append("function incYear() {\n");
sbJavascript.Append("for (i=0; i<7; i++){\n");
sbJavascript.Append("newYear = (i+nStartingYear)+1\n");
sbJavascript.Append("if (newYear==yearSelected)\n");
sbJavascript.Append(@"{ txtYear = "" <B>"" + newYear + ""</B> "" }" + "\n");
sbJavascript.Append("else\n");
sbJavascript.Append(@"{ txtYear = "" "" + newYear + "" "" }" + "\n");
sbJavascript.Append(@"document.getElementById(""y""+i).innerHTML = txtYear" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append("nStartingYear ++;\n");
sbJavascript.Append("bShow=true\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function decYear() {\n");
sbJavascript.Append("for (i=0; i<7; i++){\n");
sbJavascript.Append("newYear = (i+nStartingYear)-1\n");
sbJavascript.Append("if (newYear==yearSelected)\n");
sbJavascript.Append(@"{ txtYear = "" <B>"" + newYear + ""</B> "" }" + "\n");
sbJavascript.Append("else\n");
sbJavascript.Append(@"{ txtYear = "" "" + newYear + "" "" }" + "\n");
sbJavascript.Append(@"document.getElementById(""y""+i).innerHTML = txtYear" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append("nStartingYear --;\n");
sbJavascript.Append("bShow=true\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function selectYear(nYear) {\n");
sbJavascript.Append("yearSelected=parseInt(nYear+nStartingYear);\n");
sbJavascript.Append("yearConstructed=false;\n");
sbJavascript.Append("constructCalendar();\n");
sbJavascript.Append("popDownYear();\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function constructYear() {\n");
sbJavascript.Append("popDownMonth()\n");
sbJavascript.Append(@"sHTML = """"" + "\n");
sbJavascript.Append("if (!yearConstructed) {\n\n");
sbJavascript.Append(@"sHTML = ""<tr><td align='center' onmouseover='this.style.backgroundColor=\""#353aff\""' onmouseout='clearInterval(intervalID1);this.style.backgroundColor=\""\""' style='cursor:pointer' onmousedown='clearInterval(intervalID1);intervalID1=setInterval(\""decYear()\"",30)' onmouseup='clearInterval(intervalID1)'>-</td></tr>""" + "\n\n");
sbJavascript.Append("j = 0\n");
sbJavascript.Append("nStartingYear = yearSelected-3\n");
sbJavascript.Append("for (i=(yearSelected-3); i<=(yearSelected+3); i++) {\n");
sbJavascript.Append("sName = i;\n");
sbJavascript.Append("if (i==yearSelected){\n");
sbJavascript.Append(@"sName = ""<B>"" + sName + ""</B>""" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"sHTML += ""<tr><td id='y"" + j + ""' onmouseover='this.style.backgroundColor=\""#353aff\""' onmouseout='this.style.backgroundColor=\""\""' style='cursor:pointer' onclick='selectYear(""+j+"");event.cancelBubble=true'> "" + sName + "" </td></tr>""" + "\n");
sbJavascript.Append("j ++;\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"sHTML += ""<tr><td align='center' onmouseover='this.style.backgroundColor=\""#353aff\""' onmouseout='clearInterval(intervalID2);this.style.backgroundColor=\""\""' style='cursor:pointer' onmousedown='clearInterval(intervalID2);intervalID2=setInterval(\""incYear()\"",30)' onmouseup='clearInterval(intervalID2)'>+</td></tr>""" + "\n\n");
sbJavascript.Append(@"document.getElementById(""selectYear"").innerHTML = ""<table width=44 style='font-family:arial; font-size:11px; border-width:1; border-style:solid; border-color:#a0a0a0;' bgcolor='#3366ff' onmouseover='clearTimeout(timeoutID2)' onmouseout='clearTimeout(timeoutID2);timeoutID2=setTimeout(\""popDownYear()\"",100)' cellspacing=0>"" + sHTML + ""</table>""" + "\n\n");
sbJavascript.Append("yearConstructed = true\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("function popDownYear() {\n");
sbJavascript.Append("clearInterval(intervalID1)\n");
sbJavascript.Append("clearTimeout(timeoutID1)\n");
sbJavascript.Append("clearInterval(intervalID2)\n");
sbJavascript.Append("clearTimeout(timeoutID2)\n");
sbJavascript.Append(@"crossYearObj.visibility= ""hidden""" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function popUpYear() {\n");
sbJavascript.Append("var leftOffset\n\n");
sbJavascript.Append("constructYear()\n");
sbJavascript.Append(@"crossYearObj.visibility = (dom||ie)? ""visible"" : ""show""" + "\n");
sbJavascript.Append(@"leftOffset = parseInt(crossobj.left) + document.getElementById(""spanYear"").offsetLeft" + "\n");
sbJavascript.Append("if (ie)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("leftOffset += 6\n");
sbJavascript.Append("}\n");
sbJavascript.Append("crossYearObj.left = leftOffset\n");
sbJavascript.Append("crossYearObj.top = parseInt(crossobj.top) + 26\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("/*** calendar ***/\n");
sbJavascript.Append("function WeekNbr(n) {\n");
sbJavascript.Append("// Algorithm used:\n");
sbJavascript.Append("// From Klaus Tondering's Calendar document (The Authority/Guru)\n");
sbJavascript.Append("// hhtp://www.tondering.dk/claus/calendar.html\n");
sbJavascript.Append("// a = (14-month) / 12\n");
sbJavascript.Append("// y = year + 4800 - a\n");
sbJavascript.Append("// m = month + 12a - 3\n");
sbJavascript.Append("// J = day + (153m + 2) / 5 + 365y + y / 4 - y / 100 + y / 400 - 32045\n");
sbJavascript.Append("// d4 = (J + 31741 - (J mod 7)) mod 146097 mod 36524 mod 1461\n");
sbJavascript.Append("// L = d4 / 1460\n");
sbJavascript.Append("// d1 = ((d4 - L) mod 365) + L\n");
sbJavascript.Append("// WeekNumber = d1 / 7 + 1\n\n");
sbJavascript.Append("year = n.getFullYear();\n");
sbJavascript.Append("month = n.getMonth() + 1;\n");
sbJavascript.Append("if (startAt == 0) {\n");
sbJavascript.Append("day = n.getDate() + 1;\n");
sbJavascript.Append("}\n");
sbJavascript.Append("else {\n");
sbJavascript.Append("day = n.getDate();\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("a = Math.floor((14-month) / 12);\n");
sbJavascript.Append("y = year + 4800 - a;\n");
sbJavascript.Append("m = month + 12 * a - 3;\n");
sbJavascript.Append("b = Math.floor(y/4) - Math.floor(y/100) + Math.floor(y/400);\n");
sbJavascript.Append("J = day + Math.floor((153 * m + 2) / 5) + 365 * y + b - 32045;\n");
sbJavascript.Append("d4 = (((J + 31741 - (J % 7)) % 146097) % 36524) % 1461;\n");
sbJavascript.Append("L = Math.floor(d4 / 1460);\n");
sbJavascript.Append("d1 = ((d4 - L) % 365) + L;\n");
sbJavascript.Append("week = Math.floor(d1/7) + 1;\n\n");
sbJavascript.Append("return week;\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function constructCalendar () {\n");
sbJavascript.Append("var aNumDays = Array (31,0,31,30,31,30,31,31,30,31,30,31)\n\n");
sbJavascript.Append("var dateMessage\n");
sbJavascript.Append("var startDate = new Date (yearSelected,monthSelected,1)\n");
sbJavascript.Append("var endDate\n\n");
sbJavascript.Append("if (monthSelected==1)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("endDate = new Date (yearSelected,monthSelected+1,1);\n");
sbJavascript.Append("endDate = new Date (endDate - (24*60*60*1000));\n");
sbJavascript.Append("numDaysInMonth = endDate.getDate()\n");
sbJavascript.Append("}\n");
sbJavascript.Append("else\n");
sbJavascript.Append("{\n");
sbJavascript.Append("numDaysInMonth = aNumDays[monthSelected];\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("datePointer = 0\n");
sbJavascript.Append("dayPointer = startDate.getDay() - startAt\n\n");
sbJavascript.Append("if (dayPointer<0)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("dayPointer = 6\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"sHTML = ""<table border=0 style='font-family:verdana;font-size:10px;'><tr>""" + "\n\n");
sbJavascript.Append("if (showWeekNumber==1)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"sHTML += ""<td width=27><b>"" + weekString + ""</b></td><td width=1 rowspan=7 bgcolor='#d0d0d0' style='padding:0px'><img src='""+imgDir+""" + m_dividerGif + @"' width=1></td>""" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("for (i=0; i<7; i++) {\n");
sbJavascript.Append(@"sHTML += ""<td width='27' align='right'><B>""+ dayName[i]+""</B></td>""" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append(@"sHTML +=""</tr><tr>""" + "\n\n");
sbJavascript.Append("if (showWeekNumber==1)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"sHTML += ""<td align=right>"" + WeekNbr(startDate) + "" </td>""" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("for ( var i=1; i<=dayPointer;i++ )\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"sHTML += ""<td> </td>""" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("for ( datePointer=1; datePointer<=numDaysInMonth; datePointer++ )\n");
sbJavascript.Append("{\n");
sbJavascript.Append("dayPointer++;\n");
sbJavascript.Append(@"sHTML += ""<td align=right>""" + "\n");
sbJavascript.Append("sStyle=styleAnchor\n");
sbJavascript.Append("if ((datePointer==odateSelected) && (monthSelected==omonthSelected) && (yearSelected==oyearSelected))\n");
sbJavascript.Append("{ sStyle+=styleLightBorder }\n\n");
sbJavascript.Append(@"sHint = """"" + "\n");
sbJavascript.Append("for (k=0;k<HolidaysCounter;k++)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("if ((parseInt(Holidays[k].d)==datePointer)&&(parseInt(Holidays[k].m)==(monthSelected+1)))\n");
sbJavascript.Append("{\n");
sbJavascript.Append("if ((parseInt(Holidays[k].y)==0)||((parseInt(Holidays[k].y)==yearSelected)&&(parseInt(Holidays[k].y)!=0)))\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"sStyle+=""background-color:#FFDDDD;""" + "\n");
sbJavascript.Append(@"sHint+=sHint==""""?Holidays[k].desc:""\n""+Holidays[k].desc" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"var regexp= /\""/g" + "\n");
sbJavascript.Append(@"sHint=sHint.replace(regexp,""""")" + "\n\n");
sbJavascript.Append(@"dateMessage = ""onmousemove='window.status=\""""+selectDateMessage.replace(""[date]"",constructDate(datePointer,monthSelected,yearSelected))+""\""' onmouseout='window.status=\""\""' """ + "\n\n");
sbJavascript.Append("if ((datePointer==dateNow)&&(monthSelected==monthNow)&&(yearSelected==yearNow))\n");
sbJavascript.Append(@"{ sHTML += ""<b><a ""+dateMessage+"" title=\"""" + sHint + ""\"" style='""+sStyle+""' href='javascript:dateSelected=""+datePointer+"";closeCalendar();'><font color=#ff0000> "" + datePointer + ""</font> </a></b>""}" + "\n");
sbJavascript.Append("else if (dayPointer % 7 == (startAt * -1)+1)\n");
sbJavascript.Append(@"{ sHTML += ""<a ""+dateMessage+"" title=\"""" + sHint + ""\"" style='""+sStyle+""' href='javascript:dateSelected=""+datePointer + "";closeCalendar();'> <font color=#909090>"" + datePointer + ""</font> </a>"" }" + "\n");
sbJavascript.Append("else\n");
sbJavascript.Append(@"{ sHTML += ""<a ""+dateMessage+"" title=\"""" + sHint + ""\"" style='""+sStyle+""' href='javascript:dateSelected=""+datePointer + "";closeCalendar();'> "" + datePointer + "" </a>"" }" + "\n\n");
sbJavascript.Append(@"sHTML += """"" + "\n");
sbJavascript.Append("if ((dayPointer+startAt) % 7 == startAt) {\n");
sbJavascript.Append(@"sHTML += ""</tr><tr>""" + "\n");
sbJavascript.Append("if ((showWeekNumber==1)&&(datePointer<numDaysInMonth))\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"sHTML += ""<td align=right>"" + (WeekNbr(new Date(yearSelected,monthSelected,datePointer+1))) + "" </td>""" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append(@"document.getElementById(""content"").innerHTML = sHTML" + "\n");
sbJavascript.Append(@"document.getElementById(""spanMonth"").innerHTML = "" "" + monthName[monthSelected] + "" <IMG id='changeMonth' SRC='""+imgDir+""drop1.gif' WIDTH='12' HEIGHT='10' BORDER=0>""" + "\n");
sbJavascript.Append(@"document.getElementById(""spanYear"").innerHTML = "" "" + yearSelected + "" <IMG id='changeYear' SRC='""+imgDir+""drop1.gif' WIDTH='12' HEIGHT='10' BORDER=0>""" + "\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("function popUpCalendar(ctl, ctl2, format) {\n");
sbJavascript.Append("var leftpos=0\n");
sbJavascript.Append("var toppos=0\n\n");
sbJavascript.Append("if (bPageLoaded)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"if ( crossobj.visibility == ""hidden"" ) {" + "\n");
sbJavascript.Append("ctlToPlaceValue = ctl2\n");
sbJavascript.Append("dateFormat=format;\n\n");
sbJavascript.Append(@"formatChar = "" """ + "\n");
sbJavascript.Append("aFormat = dateFormat.split(formatChar)\n");
sbJavascript.Append("if (aFormat.length<3)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"formatChar = ""/""" + "\n");
sbJavascript.Append("aFormat = dateFormat.split(formatChar)\n");
sbJavascript.Append("if (aFormat.length<3)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"formatChar = "".""" + "\n");
sbJavascript.Append("aFormat = dateFormat.split(formatChar)\n");
sbJavascript.Append("if (aFormat.length<3)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"formatChar = ""-""" + "\n");
sbJavascript.Append("aFormat = dateFormat.split(formatChar)\n");
sbJavascript.Append("if (aFormat.length<3)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("// invalid date format\n");
sbJavascript.Append(@"formatChar=""""" + "\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("tokensChanged = 0\n");
sbJavascript.Append(@"if ( formatChar != """" )" + "\n");
sbJavascript.Append("{\n");
sbJavascript.Append("// use user's date\n");
sbJavascript.Append("aData = ctl2.value.split(formatChar)\n\n");
sbJavascript.Append("for (i=0;i<3;i++)\n");
sbJavascript.Append("{\n");
sbJavascript.Append(@"if ((aFormat[i]==""d"") || (aFormat[i]==""dd""))" + "\n");
sbJavascript.Append("{\n");
sbJavascript.Append("dateSelected = parseInt(aData[i], 10)\n");
sbJavascript.Append("tokensChanged ++\n");
sbJavascript.Append("}\n");
sbJavascript.Append(@"else if ((aFormat[i]==""m"") || (aFormat[i]==""mm""))" + "\n");
sbJavascript.Append("{\n");
sbJavascript.Append("monthSelected = parseInt(aData[i], 10) - 1\n");
sbJavascript.Append("tokensChanged ++\n");
sbJavascript.Append("}\n");
sbJavascript.Append(@"else if (aFormat[i]==""yyyy"")" + "\n");
sbJavascript.Append("{\n");
sbJavascript.Append("yearSelected = parseInt(aData[i], 10)\n");
sbJavascript.Append("tokensChanged ++\n");
sbJavascript.Append("}\n");
sbJavascript.Append(@"else if (aFormat[i]==""mmm"")" + "\n");
sbJavascript.Append("{\n");
sbJavascript.Append("for (j=0; j<12; j++)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("if (aData[i]==monthName[j])\n");
sbJavascript.Append("{\n");
sbJavascript.Append("monthSelected=j\n");
sbJavascript.Append("tokensChanged ++\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("if ((tokensChanged!=3)||isNaN(dateSelected)||isNaN(monthSelected)||isNaN(yearSelected))\n");
sbJavascript.Append("{\n");
sbJavascript.Append("dateSelected = dateNow\n");
sbJavascript.Append("monthSelected = monthNow\n");
sbJavascript.Append("yearSelected = yearNow\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("odateSelected=dateSelected\n");
sbJavascript.Append("omonthSelected=monthSelected\n");
sbJavascript.Append("oyearSelected=yearSelected\n\n");
sbJavascript.Append("aTag = ctl\n");
sbJavascript.Append("do {\n");
sbJavascript.Append("aTag = aTag.offsetParent;\n");
sbJavascript.Append("leftpos += aTag.offsetLeft;\n");
sbJavascript.Append("toppos += aTag.offsetTop;\n");
sbJavascript.Append(@"} while(aTag.tagName!=""BODY"");" + "\n\n");
sbJavascript.Append("crossobj.left = fixedX==-1 ? ctl.offsetLeft + leftpos : fixedX\n");
sbJavascript.Append("crossobj.top = fixedY==-1 ? ctl.offsetTop + toppos + ctl.offsetHeight + 2 : fixedY\n");
sbJavascript.Append("constructCalendar (1, monthSelected, yearSelected);\n");
sbJavascript.Append(@"crossobj.visibility=(dom||ie)? ""visible"" : ""show""" + "\n\n");
sbJavascript.Append(@"hideElement( 'SELECT', document.getElementById(""calendar"") );" + "\n");
sbJavascript.Append(@"hideElement( 'APPLET', document.getElementById(""calendar"") );" + "\n\n");
sbJavascript.Append("bShow = true;\n");
sbJavascript.Append("}\n");
sbJavascript.Append("else\n");
sbJavascript.Append("{\n");
sbJavascript.Append("hideCalendar()\n");
sbJavascript.Append("if (ctlNow!=ctl) {popUpCalendar(ctl, ctl2, format)}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("ctlNow = ctl\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("document.onkeypress = function hidecal1 () {\n");
sbJavascript.Append("if (event.keyCode==27)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("hideCalendar()\n");
sbJavascript.Append("}\n");
sbJavascript.Append("}\n");
sbJavascript.Append("document.onclick = function hidecal2 () {\n");
sbJavascript.Append("if (!bShow)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("hideCalendar()\n");
sbJavascript.Append("}\n");
sbJavascript.Append("bShow = false\n");
sbJavascript.Append("}\n\n");
sbJavascript.Append("if(ie)\n");
sbJavascript.Append("{\n");
sbJavascript.Append("init()\n");
sbJavascript.Append("}\n");
sbJavascript.Append("else\n");
sbJavascript.Append("{\n");
sbJavascript.Append("window.onload=init;\n");
sbJavascript.Append("}\n");
sbJavascript.Append("<");
sbJavascript.Append("/");
sbJavascript.Append("script>");
Page.Response.Write(sbJavascript.ToString());
}
protected override void Render(HtmlTextWriter writer)
{
placeJavascript();
writer.Write(@"<input type=""textbox"" name="""+this.UniqueID+@"_DatePicker"" value="""+m_text+@""" id="""+this.UniqueID+@"_DatePicker"" class="""+m_Css+@""" readonly=""readonly"" onclick=""popUpCalendar(document.all." + this.UniqueID + "_DatePicker, document.all." + this.UniqueID + "_DatePicker, '" + m_DateType + @"');"" />");
}
#endregion
}
}
|
|
|
|
|
HI,
When cutting and pasting the code I get many syntax errors. Can you provide the file for download? Or e-mail it to me?
Thanks
|
|
|
|
|
Hi Steve,
Please help me. I could not use this code because its having lot of error.
I also tried removing all syntax errors but when i gone to created Web controls then it gave me the error : "Error creating controol:Unknown Server Tag ........"
Please provide error free source code.
Thanks,
|
|
|
|
|
Has anyone fixed this yet?
I have a newer version of the class that i cleaned up if anyone is interested, it puts an image of a calendar to the right of it as well as a clear textbox image...both of these are all part of the control.
I found that sometimes users may want to leave the textbox blank, but once you set a damn date you are stuck wtih it.
I also tidied up the code a bit.
But essentially i have issues with viewstate too, has anyone got a fix for this yet?
Thanks
|
|
|
|
|
Quick Fix
I dont like this, but it will fix the problem until a cleaner solution is sorted out:
Change this:
-----------------------Original-----------------------
txtTextBox.ID = "foo";
txtTextBox.Attributes.Add("onclick", "popUpCalendar(document.all." + this.ClientID + "_foo, document.all." + this.ClientID + "_foo, '" + m_DateType + "');");
this.Controls.Add(txtTextBox);
To this:
-----------------------Improved-----------------------
txtTextBox.ID = "foo";
txtTextBox.Attributes.Add("onclick", "popUpCalendar(document.all." + this.ClientID + "_foo, document.all." + this.ClientID + "_foo, '" + m_DateType + "');");
string aClientID = this.ClientID.Replace("ctl00_", "ctl00$"); // get the client id correctly
aClientID = aClientID.Replace( "___", "$__" ) + "$";
aClientID += txtTextBox.ClientID;
txtTextBox.Text = Convert.ToString(this.Page.Request.Form[ aClientID ]); // get the form post value for this client
this.Controls.Add(txtTextBox); // THEN add the textbox to the controls collection
Again this is temporary, i dont like it, its ugly and brutal to debug...but it is working. Other than that, this is a great control!
|
|
|
|
|
Well a fix is a fix. Thanks!
|
|
|
|
|
Could you please send me the fixed dll? It would be much appreciated!!!
erik9@att.net
|
|
|
|
|
Great idea to add the calendar image and a way to clear the textbox. I would really appreciate it if you could send me your improved control.
Thank you.
AC
|
|
|
|
|
I compiled the code as a .DLL under VS.NET 2005, and added a web project to the solution. The component was automatically placed in the component toolbar, and I dragged&dropped onto the default.aspx page fine, and saw the visual placeholder for the control. Then after running the web project and testing the control, the placeholder is no longer there in design view. The control is still in the page source and runs fine when debugging the project. Has anyone else experienced design time issues?
|
|
|
|
|
I've got exactly be same problem when trying to display two datepickers on the page. One is fine the other is hidden.
|
|
|
|
|
The gif images in placeJavascript() is hard coded. It won't pick up left, right, drop down images assigned to the control.
|
|
|
|
|
Hi there,
I think we're using .net 2.0 which might be causing an issue which no one else seems to have experienced. I kept getting invalid cast errors when setting the value of the controls text box.
Here is the property which was causing the problem...
public string Text
{
get
{
if (this.Controls.Count == 0)
return "";
return ((System.Web.UI.WebControls.TextBox)Controls[1]).Text;
}
set
{
if (this.Controls.Count != 0)
{
((System.Web.UI.WebControls.TextBox)Controls[0]).Text = value;
m_text = "";
}
else
m_text = value;
}
}
Wehn I used the find control method instead of looking for the [0]th control the issue was resolved. To do this I replaced the following two lines...
Original
return ((System.Web.UI.WebControls.TextBox)Controls[0]).Text;
Replacement
return ((System.Web.UI.WebControls.TextBox)this.FindControl("foo")).Text;
Original
((System.Web.UI.WebControls.TextBox)Controls[0]).Text = value;
Replacement
((System.Web.UI.WebControls.TextBox)this.FindControl("foo")).Text = value;
Hope this helps comeone, I'd love to post a new version up here with this fix and using a string builder rather than the string contacts in their atm.
Nice free control though!!
|
|
|
|
|
Hi there,
After applying the fix, I still can't read the text value of the DatePicker Control.
(An empty string is returned whenever I tried to read the DatePicker 's text value.)
It seems that the text value of DatePicker control is not set whenever a date picked.
Can somebody help me on this. Thanks.
|
|
|
|
|
Hi Doug,
This control is really great. I made a start to replace a couple of the originals. I got a question:
* I would like to change the icon, probably this is done by changing Calendar.gif but it would be nice to do this from the propertybox
* I cannot change the position of the calendar. Something like x- and y- offset would be nice.
* I must place the control in the wwwroot. This is not very handy. What if you release a new versions that is less or not compatible with the previous. I always place controls inside my project. Something like ://localhost/someapp/controls/PopCalendar. If you can change that or tell me how it can be done..
Anyway.
This control is something to have and keep
|
|
|
|
|
Hi Skooij
Thanks, I'm glad you like the control.
In response to your querys:
* Not too sure what you mean by the "icon", but if you're referring to the images used in the control, their paths are set as properties on the control. Changing them will allow you to replace the images.
* The control was designed to align itself to the textbox. You can however download the source, and edit the javascript and control code to extend it yourself to include x and y offsets.
* The control does not have to be placed in wwwroot. In most of my projects, it resides 3 or 4 levels deep. I assume you are referring to the images not displaying correctly. If you look at all the image properties, you will see they all start with a '/'. As the control builds up the image tags to display, if the src values starts with a '/', then it will reference the images from the root of the website (as per addressing in html). To make them display properly from another location, you will have to change these properties to reference the location of the images. This is a common problem when developing using virtual directorys (VS.NET default off localhost). In this case, the root of you site is not the base folder in your project, but rather the inetpub\wwwroot folder. This is not the case when deploying to a live server though, as the project will now reside in it's own root website folder.
When in doubt, rather use relative addressing, though be carefull when you change the location of a page, as you will have to update all the links.
Hope this helps you out
Doug Wilson
|
|
|
|
|
I've trying to assign new CssClass to DataPicer TextBox but without results.
in CssClass property there is no possibilities to add any text.
I've add class name to the ControlCssClass but without result. Nothing was changed.
Css
.dlaPickera
{
font-size: 34px;
color: fuchsia;
border-top-style: ridge;
font-family: 'Palatino Linotype';
border-right-style: ridge;
border-left-style: ridge;
background-color: blue;
border-bottom-style: ridge;
}
ControlCssClass = dlaPickera
mr_ko
|
|
|
|
|
I come from China,I want to ask this question:
How to gain "2005-8-25",Not"2005 8 25".
How to Modify the code?
who can tell me.
thrank you very much.
E-Mail:aspnet2002web@yahoo.com.cn
|
|
|
|
|
Try setting the DateType to yyy-mm-dd
Doug Wilson
|
|
|
|
|
I still lose my selection after postback even when EnableViewState=True on the control. Is this by design, or I did not implement it right?
tz
|
|
|
|
|