Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

asp:calendar cannot select all dates until clicked

Posted on 2011-10-19
4
Medium Priority
?
262 Views
Last Modified: 2012-05-12
I have a asp:calendar control on a page that displays available dates dependatnt on a database query, but only one date is selectable until you click the one date that is selectable, control works fine in IE but not in chrome, firefox or safari?

Below is the link to the page the control is on and the first month is October you should be able to select 22nd and 29th but you can only select the 29th and once you have selected the 29th you can select other dates.
Similarly if you refresh the page and go direct to november you can only select the 5th but when you have selected the 5th you can select any of the other dates.

Link:  http://www.trustedvillas.co.uk/spain/rental-id-6363.html

<asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="price_Onclick" OnDayRender="CalendarDRender" BorderWidth="1px" BackColor="#F3FEFF" Width="220px"
                                                                                                                      ForeColor="#666666" CellSpacing="3" Height="180px" Font-Size="7pt" Font-Names="Verdana" BorderColor="#CCCCCC" ShowNextPrevMonth="true">
                                                                                                                       <DayHeaderStyle Font-Size="8pt" Font-Bold="True" /> <SelectedDayStyle ForeColor="White" BackColor="#FF3300" />
                                                                                                                       <TitleStyle Font-Size="11pt" Height="20" Font-Names="Trebuchet MS, Helvetica, Verdana" BorderWidth="1px" ForeColor="#FFFFFF" BorderColor="#CCCCCC" BackColor="#67A9D6" /> <OtherMonthDayStyle ForeColor="#999999" />
                                                                                                                    </asp:Calendar>

Open in new window

0
Comment
Question by:chrispaton
  • 2
  • 2
4 Comments
 
LVL 38

Expert Comment

by:Tom Beck
ID: 36992197
Can you post CalendarDRender and price_OnClick code?
0
 

Author Comment

by:chrispaton
ID: 36992224
protected void price_Onclick(object sender, EventArgs e)
    {
        sd.Attributes.Add("style", "display:none;");
        sdimg.Attributes.Add("style", "display:none;");
        gwobwctext1.Attributes.Add("style", "display:block;");
        ds.Attributes.Add("style", "display:block;"); 
        PopulateDurationDropDown();
        populatepriceform();
    }


    protected void CalendarDRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e)
    {
        e.Day.IsSelectable = false;
        string connCalendarString = ConfigurationManager.AppSettings["THConnectionString"];
        MySqlConnection cnxCalendar = new MySqlConnection(connCalendarString);
        MySqlDataAdapter adapterCalendar = new MySqlDataAdapter();
        string cmdCalendarText = "SELECT Query";
        MySqlCommand cmdCalendar = new MySqlCommand(cmdCalendarText, cnxCalendar);
        cmdCalendar.Parameters.Add(new MySqlParameter("PropertyID", HttpContext.Current.Request.QueryString["ID"]));
        DataSet dsCalendar = new DataSet();
        adapterCalendar.SelectCommand = cmdCalendar;
        adapterCalendar.Fill(dsCalendar);

        // If the month is CurrentMonth
        if (!e.Day.IsOtherMonth)
        {
            foreach (DataRow dr in dsCalendar.Tables[0].Rows)
            {
                if ((dr["StartDate"].ToString() != DBNull.Value.ToString()))
                {
                    DateTime dtEvent = (DateTime)dr["StartDate"];
                    String Avail = dr["Availability"].ToString();
                    String Bookable = dr["Bookable"].ToString();
                    if (e.Day.Date < (DateTime.Now.AddDays(-1)))
                    {
                        e.Cell.Font.Strikeout = true;
                        e.Cell.ForeColor = Color.DarkGray;
                        e.Day.IsSelectable = false;
                    }
                    else
                    {
                        if (dtEvent.Equals(e.Day.Date))
                        {
                            if (_supplier == "1")
                                {
                                    if (Avail.Equals("Y"))
                                    {
                                        if (Bookable.Equals("C"))
                                        {
                                            e.Cell.BackColor = Color.LightGreen;
                                            e.Cell.ForeColor = Color.DarkSlateGray;
                                            e.Day.IsSelectable = true;
                                        }
                                        else if (Bookable.Equals("I"))
                                        {
                                            e.Cell.BackColor = Color.LightGreen;
                                            e.Cell.ForeColor = Color.DarkSlateGray;
                                            e.Day.IsSelectable = true;
                                        }
                                        else
                                        {
                                            e.Cell.BackColor = Color.Gold;
                                            e.Cell.ForeColor = Color.LightSlateGray;
                                            e.Day.IsSelectable = false;
                                        }
                                    }
                                    else
                                    {
                                        e.Cell.BackColor = Color.IndianRed;
                                        e.Cell.ForeColor = Color.WhiteSmoke;
                                        e.Cell.Font.Strikeout = true;
                                        e.Day.IsSelectable = false;
                                    }
                                }

                                else if (_supplier == "2")
                                    {
                                        if (Avail.Equals("Y"))
                                        {
                                            if (Bookable.Equals("Y"))
                                            {
                                                e.Cell.BackColor = Color.LightGreen;
                                                e.Cell.ForeColor = Color.DarkSlateGray;
                                                e.Day.IsSelectable = true;
                                            }
                                            else
                                            {
                                                e.Cell.BackColor = Color.Gold;
                                                e.Cell.ForeColor = Color.LightSlateGray;
                                                e.Day.IsSelectable = false;
                                            }
                                        }
                                        else
                                         {
                                            e.Cell.BackColor = Color.IndianRed;
                                            e.Cell.ForeColor = Color.WhiteSmoke;
                                            e.Cell.Font.Strikeout = true;
                                            e.Day.IsSelectable = false;
                                        }
                                   }
                                else if (_supplier == "3")
                                {
                                    if (Avail.Equals("O"))
                                    {
                                        e.Cell.BackColor = Color.IndianRed;
                                        e.Cell.ForeColor = Color.WhiteSmoke;
                                        e.Cell.Font.Strikeout = true;
                                        e.Day.IsSelectable = false;
                                    }
                                    else
                                    {
                                        if (Bookable.Equals("Y"))
                                        {
                                            e.Cell.BackColor = Color.LightGreen;
                                            e.Cell.ForeColor = Color.DarkSlateGray;
                                            e.Day.IsSelectable = true;
                                        }
                                        else
                                        {
                                            e.Cell.BackColor = Color.Gold;
                                            e.Cell.ForeColor = Color.LightSlateGray;
                                            e.Day.IsSelectable = false;
                                        }
                                    }
                                }
                        }
                    }
                }
            }
        }
        else
        {
            e.Cell.Text = "";
        }
    }

Open in new window

0
 
LVL 38

Accepted Solution

by:
Tom Beck earned 2000 total points
ID: 36997585
The calendar is behaving as if there were a hidden block element partially blocking the date links. A good example of this would be if you go to the month of December. Notice that only the top half of the "3" is clickable and the "31" is clickable. It's like there's an invisible box that is tall enough to cover all the date links except the "31" and the top half of the "3". As a test, you can temporarily add position:absolute; top:300px to the table that holds the calendar. Once the calendar moves down the page 300px, you will be able to click all the date links. I cannot find the cause of the invisible box. Maybe someone else on this forum can. Another thing to note, if I recreate your page locally using the "view source" markup and the includes, I can not re-produce the problem. There may just be a syntax error in the markup OR some autogenerated script include is to blame. I did notice a pair of tags in the markup like this <itemtemplate> and a closing </itemtemplate>, but I don't believe that removing them will fix the calendar problem. Sorry I could not be of more help, but I have given it all the time I can afford.
0
 

Author Closing Comment

by:chrispaton
ID: 36998561
You were right, there was an element covering the dates. The element causing the problem was the green tick image css. I should have picked it up earlier as the onclick event for the calendar hides the green tick and the other text 'click and available' and when you can click on one of the dates the problem goes away, I was thinking that it was a problem with the calendar.

I changed the css for the image div to absolute and the problem went away, oh so simple!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Loops Section Overview
Screencast - Getting to Know the Pipeline
Suggested Courses

564 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