Solved

Calendar Control within a DetailsView

Posted on 2006-07-14
3
643 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 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

14 Experts available now in Live!

Get 1:1 Help Now