?
Solved

Date Time Picker in ASP.net using VB.net

Posted on 2005-03-24
3
Medium Priority
?
6,648 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:HanuSoftware
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Accepted Solution

by:
Faheem Shaikh earned 200 total points
ID: 13711441
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

Featured Post

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question