Solved

Calendar control - .Net

Posted on 2003-12-07
14
1,731 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
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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

832 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