Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 16th, 2005, 04:52 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
Default Calender populates a text box

I would like to be able to use a calender to populate a text box, I would like the user to click in a text box which causes the calender appear, the user then picks a date using the calender and then the chosen date appears in the text box, but I am unsure about how to do this in ASP. Net

Thanks

Louisa


 
Old May 16th, 2005, 05:48 AM
Authorized User
 
Join Date: Jul 2004
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Write this code in the aspx file:

function pickDate(Src,lt)
{
window.open("CalendarPopUp.aspx?src=" + Src, "_blank", "height=160,width=240,left=" + lt + ",top=75," + "location=no,menubar=no,resizable=no,scrollbars=no ,titlebar=no,toolbar=no", true);

}

The above function needs to be called in the specific event of
the textbox :
onkeypress="pickDate('txtFromdt',50);"



In the code behind of CalendarPopUp.aspx write this:

Dim sbScript As New StringBuilder
sbScript.Append("<script language='javascript'>")
sbScript.Append(Environment.NewLine)
sbScript.Append("window.opener.document.forms[0].")
sbScript.Append(Request.QueryString("src"))
sbScript.Append(".value = '") //displays the date selected in calendar in
                                       //the textbox
sbScript.Append(Calendar1.SelectedDate.ToString("d d/MM/yyyy"))
sbScript.Append("';")
sbScript.Append(Environment.NewLine)
sbScript.Append("window.close();")
sbScript.Append(Environment.NewLine)
sbScript.Append("</script>")
RegisterStartupScript("CloseWindow", sbScript.ToString)

PLease note that i had used the above code to invoke the calendar
control on the click of a image. You will have to make some
changes to the code

 
Old May 16th, 2005, 06:03 AM
Authorized User
 
Join Date: Jul 2004
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oops...forgot to mention that you need to add the above
StringBuilder code in the SelectionChanged event of the
calendar (CalendarPopUp.aspx)

Just now i tried this code on the click of textbox and it
worked fine.

Cheers
Spacy







Similar Threads
Thread Thread Starter Forum Replies Last Post
Grab Values From List Box into Text Box phungleon VB How-To 2 June 19th, 2008 10:33 PM
Count in combo box(display results in text box) mboyisis Access 4 April 4th, 2008 07:08 AM
Extract text from text file & put in dropdown box tsukey Beginning PHP 5 July 20th, 2004 09:49 PM
Rich Text Box vs Text Box snowy0 VB.NET 2002/2003 Basics 1 February 17th, 2004 02:11 PM
Search using drop down list box and a text box tcasp Classic ASP Basics 1 July 31st, 2003 02:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.