Solved

Calendar Control within a DetailsView

Posted on 2006-07-14
3
644 Views
Last Modified: 2012-06-27
I have a textbox where you need a date, I have an icon next to it which is a calendar, i would like to make the field populate with the date after you click on the icon. When you click on the icon, a calendar needs to visible. I tried the calendar control with some javascript and it doesn't work. I think I need a form tag.

<asp: DetailsView ID="DV1">
<asp: textbox name="date"/>
<asp: Calendar ID="dateCalendar">
...
</asp: Calendar>
</asp: DetailsView>

Could you help me on this? I don't know if the Calendar works in the DV?
0
Comment
Question by:marcivry
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
Sammy earned 250 total points
ID: 17111999
marcivry,
take a look at this post. I have already answered this kind of question here and the solution works fine with a div
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_21912671.html

heres the code

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="TestCalendar.vb" Inherits="TestCalendar" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
<script type="text/javascript">
function ToggleCal(){
if(document.getElementById('divCal').style.display=='none')
document.getElementById('divCal').style.display='block'
else
document.getElementById('divCal').style.display='none';
}
</script>
</head>
<body>
    <form id="form1" runat="server">
<div>
<asp:Label ID="lblDate" runat="server" CssClass="lbl" Text="Click Here To View Calendar"></asp:Label>
</div>
<div id="divCal" style="position: absolute; right: 380px; top: 330px; display: none;">
                        <asp:Calendar ID="CalBook" runat="server" NextMonthText=" >" CssClass="Cal" NextPrevStyle-CssClass="NextPrev" TodayDayStyle-CssClass="TodayStyle"
                            DayStyle-CssClass="DayStyle" ShowGridLines="true" NextPrevFormat="ShortMonth">
                            <WeekendDayStyle CssClass="WeekendStyle" />
                            <OtherMonthDayStyle CssClass="OtherMonthDayStyle" />
                            <SelectedDayStyle CssClass="SelectedDayStyle" />
                            <DayHeaderStyle CssClass="DayHeader" />
                            <TitleStyle CssClass="TitleStyle" />
                            <DayStyle CssClass="DayStyle" />
                            <NextPrevStyle CssClass="NextPrev" />
                        </asp:Calendar>
                    </div>
 </form>
</body>
</html>

HTH
0
 
LVL 27

Expert Comment

by:Sammy
ID: 17112083
one more thing I just seen your DetailView and you can use something like this

Protected Sub CalBook_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CalBook.SelectionChanged
        Dim Tempcal as calendar=Ctype(me.DetailView.rows.item(the index where the control is in the detailview),Calendar) 'declare the control and cast it

Me.lblDate.Text = TempCal.SelectedDate.ToShortDateString 'show the selected date in the label control

        CalBook.VisibleDate = Me.CalBook.SelectedDate 'make sure the calendar control knows which date is selected when its hidden

    End Sub

HTH
0
 

Author Comment

by:marcivry
ID: 17124607
When you state index of the control, do you mean, where is it in relationship to the other controls?

I have listed:

First Name
Last Name
SS#
Symbol
Rank
Birth Date

Birthdate is where i want the calendar to show so the index is 5?

Also, div tags are not allowed in the DetailsView in .NET, so how do you remedy that?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now