Solved

Calendar control - .Net

Posted on 2003-12-07
14
1,730 Views
Last Modified: 2013-12-03
Trying to get Calendar control to post value to one of my textboxes in asp.net
Also want to format my calendar control to be much smaller in box size as well as show the calendar in separate window when user clicks on an icon.

Need some general code ideas using a calendar control and a basic textbox control in asp.net as well as how to format the size of window and text....and get the calendar control to pop up in a window before it posts the date selected back to the textbox.
0
Comment
Question by:dba123
  • 7
  • 5
14 Comments
 
LVL 35

Accepted Solution

by:
YZlat earned 500 total points
Comment Utility
just change height and width properties in the control below to the desired size.
Then save the page with a control as caledar.aspx page and use javascript function to open it in a separate window.


<asp:Calendar ID="myDates"
              CellPadding = "2"
              CellSpacing = "2"
              BackColor="Ivory"
              ForeColor="Navy"
              Font-Name="Verdana"
              Font-Size="12pt"
              Font-Bold="True"
              Height="200"
              Width="400"
              TitleStyle-BackColor="#3366FF"
              TitleStyle-ForeColor="White"
              TitleStyle-Font-Bold="True"
              DayHeaderStyle-Font-Bold="True"
              DayHeaderStyle-Font-Italic="True"
              DayHeaderStyle-ForeColor="Red"
              NextPrevStyle-Font-Italic="True"
              NextPrevStyle-BackColor="Ivory"
              WeekEndDayStyle-Font-Italic="True"
              WeekEndDayStyle-ForeColor="Green"
              OtherMonthDayStyle-Font-Italic="True"
              OtherMonthDayStyle-BackColor="White"
              OtherMonthDayStyle-ForeColor="Gray"
              SelectedDayStyle-BackColor="#3366FF"
              OnSelectionChanged="YOUR FUNCTION"
              Runat="server">
</asp:Calendar>
0
 
LVL 35

Expert Comment

by:YZlat
Comment Utility
put this in the <head> section of your page from which you'll be opening your calendar page
<script language="JavaScript">

<!--//

function get_calendar(url) {

link = window.open(url,"myCalendar","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=600,height=500,left=40,top=50");

}
//-->
</script>


then you can assign javascript function to href attribute of a button:
myButton.Attributes.Add("href", "javascript:get_calendar('calendar.aspx')")
0
 
LVL 1

Author Comment

by:dba123
Comment Utility
Ok, thanks for the properties of the calendar control but for the button, I am using an ASP.Net button.  I don't think mybutton.attributes.add is ASP.NET, isn't this javascript?

please inform how I would form my button to call the function and then also how I would grab the value that the user selects from the calendar to be the value of my TextBox
0
 
LVL 1

Author Comment

by:dba123
Comment Utility
using ASP.Net, not JavaScript
0
 
LVL 1

Author Comment

by:dba123
Comment Utility
I know ASP uses JavaScript for some of the functions so fill me in on the Button control for launching and positioning the calendar then grabbing the value
0
 
LVL 1

Author Comment

by:dba123
Comment Utility
I got it to work.  After I click on the calendar, I figure out logic to get it in the textbox.  Now all I need remining is how to pop the calendar up when the user clicks on the button
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 1

Author Comment

by:dba123
Comment Utility
Can I use CSS or DHTML to position my calendar next the the button after I click the asp imagebutton?
0
 
LVL 1

Author Comment

by:dba123
Comment Utility
I can figure out the positioning the rest of the way and will use the Visible property of the calendar control.

thanks
0
 
LVL 35

Expert Comment

by:YZlat
Comment Utility
myButton.Attributes.Add("href", "javascript:get_calendar('calendar.aspx')")
is asp.net code that calls a javaScript to open a new window
0
 
LVL 35

Expert Comment

by:YZlat
Comment Utility
or you can use a hyperlink to open a new window:

<asp:hyperlink target=_blank NavigateUrl="calendar.aspx" Runat="server">Open</asp:hyperlink>
0
 
LVL 35

Expert Comment

by:YZlat
Comment Utility
AnnieMod, why should question be closed, I pretty much answered it and  dba123 said it was working?
I tested it myself and it is working. Why shouldn't I get the points?
0
 
LVL 1

Author Comment

by:dba123
Comment Utility
Let me work with YZlat on his suggestion.

YZlat, I couldn't find this in my ASP.Net book.  Where do I put myButton.Attributes.Add?  in a sub function?  or in the conrol itself.  Any resources on attributes such as what you just gave me?  I'll look also and try getting it to work as you suggested again.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

728 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

10 Experts available now in Live!

Get 1:1 Help Now