Date Time Picker in ASP.net using VB.net

Hi friends
Help me out from this Date Time Picker


I am using the Microsoft Date Time Picker from COM component of ASP.net using VB.net.I am enable to get the value of Date Time Picker in the variable in VB.net


Thanks for Help
HanuSoftwareAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Faheem ShaikhCommented:
Even I had such a problem once.
The solution is to not to use Date Time Picker from COM component .
Instead use this calendar in ASP Whose code is as follows:
Just give it some time and modify it as per your requirements.
It is not a readymade component so you can have complete control over its functionality.

The code is::

<%
Response.Expires = 0

if len(trim(Request.QueryString("cDate"))) > 0 and isDate(Request.QueryString("cDate")) = True then
curDate = cdate(Request.QueryString("cDate"))
curMonth = month(curDate)
curYear = year(curDate)

else

if len(trim(curMonth)) < 1 then
curMonth = Request("cMonth")
end if
if len(trim(curMonth)) < 1 then
curMonth = month(date)
end if

curYear = Request("cYear")
if len(trim(curYear)) < 1 then
curYear = year(date)
end if

curDate = cdate(day(date) & "." & cdbl(curMonth) & "." & cdbl(curYear))

end if

if weekday(dateadd("d",((day(curDate)-1)* -1),curdate),2) = 1 then
Firstday = dateadd("d",((day(curDate)-1 + 7)* -1),curdate)
else
Firstday = dateadd("d",((day(curDate)-1 + weekday(dateadd("d",((day(curDate))* -1),curdate),2)) * -1),curdate)
end if
%>
<HTML>
<Head>
<Title>Datepicker&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</Title>
<%
RecObj = Request.QueryString("backf")
RecObj1 = Request.QueryString("backf1")
Response.Write "<Script language='javascript'> "
Response.Write "var l_SelDate;   "
Response.Write "var l_SelWeek;  "
Response.Write "function SetDate(aDate,i,j) "
Response.Write "{  "
Response.Write "var z; "
Response.Write "if( j == 53 ) { "
Response.Write "j=0 ;  "
Response.Write "}  "
Response.Write "if( j == 52 ) { "
Response.Write "j=0 ;  "
Response.Write "}  "
Response.Write "z = i - j + 1 ;  "
Response.Write "if( z == 54 ) { "
Response.Write "z=1 ;  "
Response.Write "}  "
Response.Write "l_SelDate = aDate; "
Response.Write "l_SelWeek = z; "

Response.Write "} "


Response.Write "function PutDate() "
Response.Write "{  "
Response.Write "if(l_SelDate == null) { "
Response.Write "alert('Please Select A Date.');  "
Response.Write "}  "
Response.Write "else {  "
Response.Write "window.opener." & RecObj & ".value = l_SelDate; "
Response.Write "window.opener." & RecObj1 & ".value = l_SelWeek; "
Response.Write "window.close(); "
Response.Write "}  "
Response.Write "} "

Response.Write "</Script> "
%>
<Script language="javascript">

window.moveTo((window.screen.width - 300),(window.screen.height - 125)/2);

function cib(o,Nr)
{
if (Nr == "on")
{
o.style.background = "#F7BF47";
}
else
{
o.style.background = "#D5D1C8";
}
}

</Script>

<Style type="text/css">
TD {Font-family:tahoma, Arial, Verdana; font-weight:400; font-size: 8pt; color:#000000;}
.INPUTComb {Font-family:tahoma, Arial, Verdana; font-weight:400; font-size: 7pt; color:#000000;}
.CalDay {Font-family:tahoma, Arial, Verdana; font-weight:600; font-size: 8pt; color:#0000a0; text-align: left; width:35px; height:25px; background-color: #D5D1C8; border-left: 1px #ffffff solid; border-top: 1px #ffffff solid; border-right: 1px #000000 solid; border-bottom: 1px #000000 solid; cursor:hand}
.INPUTBUTTON {Font-family:Tahoma, Verdana, Arial; font-weight:400; font-size: 8pt; color:#0000a0; background-color: #D5D1C8; border-left: 1px #ffffff solid; border-top: 1px #ffffff solid; border-right: 1px #000000 solid; border-bottom: 1px #000000 solid; cursor:hand}
A:link {Font-family: Tahoma, Arial, Verdana; Font-size: 12pt; Font-weight: 600; color: #000000; text-decoration: none;}
A:active {Font-family: Tahoma, Arial, Verdana; Font-size: 12pt; Font-weight: 600; color: #000000; text-decoration: none;}
A:visited {Font-family: Tahoma, Arial, Verdana; Font-size: 12pt; Font-weight: 600; color: #000000; text-decoration: none;}
A:hover {Font-family: Tahoma, Arial, Verdana; Font-size: 12pt; Font-weight: 600; color: #00cc00; text-decoration: none;}
</Style>

</Head>

<Body onLoad="javascript:window.focus()" bgcolor="#e9e9e9" leftmargin=5 topmargin=2 rightmargin=5 bottommargin=5>

<Form method="Post" action="datepicker.asp?backf=<%Response.Write RecObj%>" name="CalForm">

<Table border="0" width="100%" height="30" cellpadding="0" cellspacing="0">
<TR>
<TD width="20"><Input type="Button" class="INPUTBUTTON" onClick="javascript:window.document.location.href='datepicker.asp?backf=<%Response.Write RecObj%>&cDate=<%Response.write dateadd("m", -12, curDate)%>&backf1=<%Response.Write RecObj1%>'" Value="<<" id=Button1 name=Button1></TD>
<TD width="20"><Input type="Button" class="INPUTBUTTON" onClick="javascript:window.document.location.href='datepicker.asp?backf=<%Response.Write RecObj%>&cDate=<%Response.write dateadd("m", -1, curDate)%>&backf1=<%Response.Write RecObj1%>'" Value="<" id=Button1b name=Button1b></TD>
<TD width="80" align=center><Font size=2><B><%Response.write monthname(curMonth,2)%>&nbsp;<%Response.write curYear%></B></Font></TD>

<TD width="20" align=right>&nbsp;<Input type="Button" class="INPUTBUTTON" onClick="javascript:window.document.location.href='datepicker.asp?backf=<%Response.Write RecObj%>&cDate=<%Response.write dateadd("m", 1, curDate)%>&backf1=<%Response.Write RecObj1 %>'" Value=">" id=Button2 name=Button2></TD>
<TD width="20"><Input type="Button" class="INPUTBUTTON" onClick="javascript:window.document.location.href='datepicker.asp?backf=<%Response.Write RecObj%>&cDate=<%Response.write dateadd("m", 12, curDate)%>&backf1=<%Response.Write RecObj1%>'" Value=">>" id=Button2b name=Button2b></TD>
</TR>
</Table>



<Table border="0" width="280" cellpadding="0" cellspacing="0">
<TR>
<TD width=50 align=center><%Response.Write DatePart("ww",FirstDay, vbMonday, vbFirstFourDays) %></TD>
<%For i = 0 to 41%>
<%If (i = 7 or i = 14 or i = 21 or i = 28 or i = 35) then%></TR><TR><TD width=50 align=center><%Response.Write DatePart("ww", dateadd("d", i, FirstDay), vbMonday, vbFirstFourDays)%></TD><%end if%>
<TD width=35 align=center><Input type="Button" <%If month(dateadd("d", i, FirstDay)) <> month(curDate) then Response.Write "style='color: #808080; font-weight:400;'" end if%> <%If dateadd("d", i, FirstDay) = Date then Response.write "style='font-size=10pt; border-left: #FF0000 1px solid; border-top: #FF0000 1px solid; border-right: #FF0000 1px solid; border-bottom: #FF0000 1px solid; '" end if%> class="CalDay" onmouseover="cib(this,'on')" onmouseout="cib(this,'off')" onClick="javascript:SetDate('<%Response.Write dateadd("d",i,FirstDay)%>',<%Response.Write DatePart("ww", dateadd("d", i, FirstDay), vbMonday, vbFirstFourDays)%> ,<%Response.Write  DatePart("ww",  FirstDay, vbMonday, vbFirstFourDays)%> )" Value="&nbsp;<%Response.write day(dateadd("d", i, FirstDay))%>"></TD>
<%Next%>
</TR>
</Table>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" value="Close" name="cmdClose"  onClick="PutDate()" style="border:1px solid #006699; width: 100; color:#006699; font-weight:bold" tabindex="">&nbsp;
<input type="button" value="Cancel" name="cmdReset" onClick="javascript:window.close()" tabindex="" style="border:1px solid #006699; width: 100; color:#006699; font-weight:bold">
</Form>

</Body>
</HTML>

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.