Wrox Programmer Forums
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET 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 December 8th, 2004, 07:39 AM
Registered User
 
Join Date: Dec 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to dinkarsinha
Default Caleder Control

Can u tell me that what property should i use in textbox so that after clicking it ,a calender pop up window opens and after clicking on calender it posts the date to the textbox area.Please suggest me the whole process n if possible the code too.
Regards
Dinkar

Dinkar Sinha
 
Old December 8th, 2004, 09:45 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You first initialise the calendar and write this code on selection index change of calendar. Code is


private void Calendar1_SelectionChanged(object sender, System.EventArgs e)
        {
        TextBox1.Text=Calendar1.SelectedDate.ToShortDateSt ring();
        }



Lily

 
Old December 10th, 2004, 06:49 AM
Registered User
 
Join Date: Dec 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to dinkarsinha
Default

Ya it will work fine if all controls are on the same page.But i am popping up the calender window .So i have to either maintain a viewstate or use dopostback.Any other method.I am using ASP.NET

Dinkar Sinha
 
Old December 13th, 2004, 06:10 PM
Authorized User
 
Join Date: Jan 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to rathbird
Default

I have an image I use to popup a new window. I have an onclick event for this image which calls the following js function:

<script language="javascript">
<!--
    function PopUp(textbox)
    {
      window.open('datepicker_calendar.aspx?Date=' + '6/8/2004' + '&ControlID=' + textbox,'DatePickerWindow','width=170,height=165,s tatus=0,resizeable=0,scrollbars=0');
    }
-->
</script>

This function passes the textbox form field ID to the popup page and when you select a date on the calendar, it populates the textbox. The code for the popup page looks like this (and most of the code is just formatting of the calendar control):

<HTML>
    <HEAD>
        <title>Select Date</title>
        <script language="javascript">
     // this will determine the value and return it to the opening page
    function SelectDate(SelectedDate)
    {
        var textboxid = document.Form1.hdnID.value;
        window.opener.document.Form1.elements[textboxid].value = SelectedDate;
        self.close();
    }
        </script>
    </HEAD>
    <body topmargin=0 leftmargin=0>
        <form id="Form1" method="post" runat="server">
            <asp:calendar id="Calendar1" runat="server" OnVisibleMonthChanged="month_click" OnDayRender="Calendar1_DayRender"
                bordercolor="#3366CC" Width="170px" Height="160px" Font-Size="8pt" BorderWidth="1px" BackColor="White"
                DayNameFormat="FirstLetter" ForeColor="#003399" Font-Names="Verdana" CellPadding="1">
                <TodayDayStyle ForeColor="White" BackColor="#99CCCC"></TodayDayStyle>
                <SelectorStyle ForeColor="#336666" BackColor="#99CCCC"></SelectorStyle>
                <NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF"></NextPrevStyle>
                <DayHeaderStyle Height="1px" ForeColor="#336666" BackColor="#99CCCC"></DayHeaderStyle>
                <SelectedDayStyle Font-Bold="True" ForeColor="#CCFF99" BackColor="#009999"></SelectedDayStyle>
                <TitleStyle Font-Size="10pt" Font-Bold="True" Height="25px" BorderWidth="1px" ForeColor="#CCCCFF"
                    BorderStyle="Solid" BorderColor="#3366CC" BackColor="#003399"></TitleStyle>
                <WeekendDayStyle BackColor="#CCCCFF"></WeekendDayStyle>
                <OtherMonthDayStyle ForeColor="#999999"></OtherMonthDayStyle>
            </asp:calendar><INPUT id="hdnID" type="hidden" value="<%=Request.QueryString["ControlID"]%>">
        </form>
    </body>
</HTML>

Hope that helps

 
Old December 16th, 2004, 04:08 AM
Registered User
 
Join Date: Dec 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to dinkarsinha
Default

Dear Robin
Thanks for giving me the complete details through coding but dear it is still not working.Actually i am popping the window form from a control(.ascx) file after several links therefore i think it might be the problem.Can u suggest something new.Popping the window is right and working fine but it is not posting the date back to textbox neither it is closing itself although i used both window.close and self.close.. can u suggest some codebehind and through proper functions without using javascript(offcourse if possible)..Anyway thanks again for all the support.
Dinkar

Dinkar Sinha
 
Old December 17th, 2004, 01:07 PM
Authorized User
 
Join Date: Jan 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to rathbird
Default

Dinkar,

I think the problem with the code I supplied is that it is for a web application and you're looking for a solution for a windows application. I do most programming for the web, but I believe that a modal dialog is the solution for your windows app. I unfortunately don't have any code that will help you, but I did see other threads on the calendar control that might be helpful.

Robin

 
Old December 18th, 2004, 03:04 AM
Registered User
 
Join Date: Dec 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to dinkarsinha
Default

Hi Robin
Here you got me wrong.No dear i am currently working on web application and as i have told you that i can't post back the data from the Calendar webform to my user control that is textbox.Dear the problem is in JavaScript running because it can't find the object of the control page and therefore it is not executing.Ya it will be simple if i post data back to a aspx page but as i hv told u that it will be very cumbersome for me to change my whole project.So please tell me a method so that javascript can run smoothly and post data back to the textbox.Really i need yr help.Thanks in advance.

Dinkar Sinha
 
Old December 23rd, 2004, 07:55 AM
Registered User
 
Join Date: Dec 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to dinkarsinha
Default

I got it what was wrong.Actually what i was passing the id of server control and by default it changes at client side.Therefore changed it to the clientside id and then it starts working.But not sure whether it will continue to work properly bcoz client side ID may change anytime.Please suggest.Or it will continue working properly.i was using initially txtAddEffectiveDate and now changed it after viewing source to _ct10_txtAddEffectiveDate and it is working currently.



Dinkar Sinha





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to put a button control in a GridView control ryan.webb ASP.NET 2.0 Basics 2 December 28th, 2007 05:26 AM
Can't move focus to control <control scptech Access VBA 8 October 26th, 2007 12:16 PM
display total per week left to the caleder control veeruu ASP.NET 2.0 Basics 0 March 12th, 2007 09:23 AM
display total per week left to the caleder control veeruu ASP.NET 2.0 Professional 0 March 12th, 2007 09:20 AM
Help! Custom Server Control using User Control diehard ASP.NET 1.0 and 1.1 Professional 2 January 4th, 2006 12:33 PM





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