Solved

ASP.NET Calendar IsSelectable false

Posted on 2006-11-02
4
229 Views
Last Modified: 2012-06-27
hi, im having a problem on my asp calendar.

It is currently reading in data from a database.

I want it to be able to disallow somone from clicking on a date which has text in it.

here is my code.

      protected void eventscalendar_DayRender(Object Src, DayRenderEventArgs E)
      {
            StringBuilder strEvents = new StringBuilder();
            strEvents.Append("<span style=\"font-size:80%\">");
            
            foreach (DataRow row in ds.Tables["events"].Rows)
            {
                  DateTime eventdate = (DateTime)row["eventdate"];
                  if (eventdate.Equals(E.Day.Date))
                        strEvents.Append("<br />" + row["eventtext"]);            
            }
            strEvents.Append("</span>");
            E.Cell.Controls.Add(new LiteralControl(strEvents.ToString()));
            }

i have tried this

      if (E.Cell.Controls.Count == 1)
      {
      E.Day.IsSelectable=false;
      }

and

E.Day.IsSelectable=false;

but it either disables all the dates or doesnt.

can anyone help me?

thanks
0
Comment
Question by:thomasmutton
4 Comments
 

Author Comment

by:thomasmutton
ID: 17859466
ok i solved it myself

i used

protected void eventscalendar_DayRender(Object Src, DayRenderEventArgs E)
      {
            StringBuilder strEvents = new StringBuilder();
            strEvents.Append("<span style=\"font-size:80%\">");
            
            foreach (DataRow row in ds.Tables["events"].Rows)
            {
                  DateTime eventdate = (DateTime)row["eventdate"];
                  if (eventdate.Equals(E.Day.Date))
                  {
                        strEvents.Append("<br />" + row["eventtext"]);      
                        E.Day.IsSelectable=false;
                  }
                  
                  if (E.Cell.Text == null)
                  {
                        E.Day.IsSelectable=true;
                  }
                                                      
            strEvents.Append("</span>");
            E.Cell.Controls.Add(new LiteralControl(strEvents.ToString()));
            }      
      }
0
 
LVL 16

Expert Comment

by:ellandrd
ID: 17861406
OK open a 0 point question in CS to request for this question to be closed.

ellandrd ;-)
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 18062132
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now