Solved

Calendar control - .Net

Posted on 2003-12-07
14
1,735 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
[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
  • 7
  • 5
14 Comments
 
LVL 35

Accepted Solution

by:
YZlat earned 500 total points
ID: 9897957
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
ID: 9898039
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
ID: 9901783
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 1

Author Comment

by:dba123
ID: 9901802
using ASP.Net, not JavaScript
0
 
LVL 1

Author Comment

by:dba123
ID: 9901805
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
ID: 9901840
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
 
LVL 1

Author Comment

by:dba123
ID: 9901849
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
ID: 9901859
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
ID: 9903821
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
ID: 9903896
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
ID: 9903910
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
ID: 9932904
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

624 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