p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 2.0 Basics (http://p2p.wrox.com/forumdisplay.php?f=136)
-   -   Calendar Control in a wizard (http://p2p.wrox.com/showthread.php?t=45810)

frosty July 28th, 2006 01:26 AM

Calendar Control in a wizard
 
I have a calendar control in a wizard, and i would like to set the days prior to today's date as unselectable.

    protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {

        if (e.Day.Date < DateTime.Today)
        {
            Wizard1.FindControl("Calendar1").e.Day.IsSelectabl e = false;
            e.Cell.BackColor = System.Drawing.Color.Black;
        }
    }

I know that isn't going to work, but I have been trying a bunch of different combinations, any help would be appreciated.
Thanks.



frosty July 28th, 2006 12:12 PM

This is why i won't buy another wrox book. I have spent over $100 on beginning asp.net 2.0 and professional asp.net 2.0 and they only cover the most basic scenarios. If anyone can tell me where the answer to this question can be found in either of those books I would be more than happy to answer this question myself. But for the life of me, I can't find anywhere those books reference how to expose these properties from within another control. I understand the scope of these books is not to teach someone how to program, but a few examples of situations outside the box would go a long way in helping people figure it out.


Imar July 28th, 2006 12:14 PM

Hi there,

Isn't it as simple as:

e.Day.IsSelectable = false;

??

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004

Imar July 28th, 2006 12:27 PM

I think your post just crossed mine.

I understand what you're saying about these books. However, there are so many topics available, it's not difficult to find something that's not discussed. I don't have those books, but I can imagine they do discuss FindControl somewhere?

Although you said you don't want Wrox books anymore, you could take a look at books like ASP.NET 2.0 Instant Results or ASP.NET 2.0 Website Programming: Problem - Design - Solution, also by Wrox.

Instead of discussing many separate topics, these books cover more complicated applications, zooming in on the more advanced features of ASP.NET.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004

frosty July 28th, 2006 12:43 PM

Sorry Imar, I was throwing a temper tantrum after working on such a simple thing for the last 12 hours. I think I need to get some more books. But in any case, the problem is that the event is not getting called. Anything I put in that function doesn't happen.

the calendar is just

<asp:Calendar ID=Calendar1" runat="server"></asp:Calendar>

 within step one of the wizard. and the text for the function is

   protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {

        if (e.Day.Date < DateTime.Today)
        {
            e.Day.IsSelectable = false;
            e.Cell.BackColor = System.Drawing.Color.Black;
        }
    }


Imar July 28th, 2006 12:51 PM

Right. That explains a lot. You need to tell the calendar what method is responsible for handling the event:

<asp:Calendar ID="Calendar1" runat="server"
   OnDayRender="Calendar1_DayRender"></asp:Calendar>

Otherwise, your Calendar1_DayRender method is just a simple method, and not an event handler for the DayRender event....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004


All times are GMT -4. The time now is 04:11 AM.

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