Solved

Calendar control - .Net

Posted on 2003-12-07
14
1,734 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

734 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