ASP.NET - Please read the following post, which was mentioned below.[URGENT]

Asked By Venkatesh Desai on 14-May-12 03:49 AM
Earn up to 10 extra points for answering this tough question.

Hi All,


I am Doing Calendar Events.
I am getting my events from Database.
I U Observe The Image U can understand that the events are with Green Colored.
E.g., like 1,2,3,4,6,7 & 8.

My Task Is that When My cursor would be placed on 1 & when I click on that 1 it wants to be opened new page.

 

Here When I am keeping my cursor on 1 the background Is changing with Red & Fore color is changing to White I u observe the Image.

But My Problem is that it was not getting Link That means when I keep the cursor on day 1 cell it cant change like HAND SYMBOL.

If I get HAND SYMBOL At that place my work gets simple.

 
My Image Is,


Please check my code if there is any mistakes,

 

My Code Goes Like This,

 

protected void EventsCalendar_DayRender(object sender, DayRenderEventArgs e)

    {

      string onmouseoverStyle = "this.style.backgroundColor='Red';this.style.color='White'";

      string onmouseoutStyle = "this.style.backgroundColor='#F0F7EF';this.style.color='Green'";

 

      e.Cell.Enabled = false;

 

      DataSet ds = GetEventsCalendarDetails();

 

      string link = "<a href='EventScheduleDetails.aspx?EventID=";

 

      string s = e.Day.Date.ToShortDateString();

 

      e.Cell.Text = e.Day.Date.Day.ToString() + "<BR>";

 

      LinkButton l = new LinkButton();

      l.Text = e.Day.Date.Day.ToString() + "<BR>";

      e.Cell.Controls.Add(l);

 

      if (ds != null)

      {

        if (ds.Tables.Count > 0)

        {

          if (ds.Tables[0].Rows.Count > 0)

          {

            foreach (DataRow row in ds.Tables[0].Rows)

            {

             

              int EventID = Convert.ToInt32(row["EventID"]);

              string EventTitle = row["Title"].ToString();

              string EventStartDate = Convert.ToDateTime(row["StartDate"]).ToShortDateString();

              string EventEndDate = Convert.ToDateTime(row["EndDate"]).ToShortDateString();

 

              if (EventStartDate.Equals(s))

              {

                e.Cell.Enabled = true;

                e.Cell.ForeColor = System.Drawing.Color.Green;

                e.Cell.Style.Add("background-color", "#F0F7EF");

 

                LinkButton lnk = new LinkButton();

                lnk.Text = link + (int)row["EventID"] + "'>";

                lnk.Attributes.Add("onclick", "window.open('" + link + "');");

                e.Cell.Controls.Add(lnk);

 

                e.Cell.Attributes.Add("onmouseover", onmouseoverStyle);

                e.Cell.Attributes.Add("onmouseout", onmouseoutStyle);

              }

            }

          }

        }

      }

    }

 


Thanks In Advance,

VenkiDesai.

[)ia6l0 iii replied to Venkatesh Desai on 14-May-12 09:26 PM
Add the cursor as a Cell Style. Please look below. 

if (EventStartDate.Equals(s))

{

          e.Cell.Enabled = true;

          e.Cell.ForeColor = System.Drawing.Color.Green;

          e.Cell.Style.Add("background-color", "#F0F7EF");

 

          LinkButton lnk = new LinkButton();

          lnk.Text = link + (int)row["EventID"] + "'>";

          lnk.Attributes.Add("onclick", "window.open('" + link + "');");

          e.Cell.Controls.Add(lnk);

 

          e.Cell.Attributes.Add("onmouseover", onmouseoverStyle);

          e.Cell.Attributes.Add("onmouseout", onmouseoutStyle); e.Cell.Style.Add("cursor", "hand"); 

}


Venkatesh Desai replied to [)ia6l0 iii on 15-May-12 12:48 AM
Thanks For Replying [)ia6l0 iii 
Good That Hand Cursor is coming.
But The Link was not coming that means it was not opening in separate window.
In the below code, There was no use of keeping the Dynamic LinkButton.B'coz if i keep with (OR) without Comments also the result is same, Separate window is not opening.

if (EventStartDate.Equals(s))

{

        e.Cell.Enabled = true;

      e.Cell.ForeColor = System.Drawing.Color.Green;

      e.Cell.Style.Add("background-color", "#F0F7EF");

       

          // LinkButton lnk = new LinkButton();


          // lnk.Text = link + (int)row["EventID"] + "'>";

          // e.Cell.Attributes.Add("onclick", "window.open('" + link + "');");

          // e.Cell.Controls.Add(lnk);

 

      e.Cell.Attributes.Add("onmouseover", onmouseoverStyle);

      e.Cell.Attributes.Add("onmouseout", onmouseoutStyle); 

      e.Cell.Style.Add("cursor", "hand"); 

}


Vikram Singh Saini replied to Venkatesh Desai on 15-May-12 01:40 AM
Have you read the article at http://weblogs.sqlteam.com/jhermiz/archive/2007/12/10/Cool-Tricks-With-The-ASP.net-Calendar.aspx

It explains your problem scenario with explanation and screenshots.
Venkatesh Desai replied to Vikram Singh Saini on 15-May-12 03:10 AM
Thanks Vikram For Replying,

Suppose i want to pass a calendar day to a Response.Redirect to another page when i click on a calendar day. 

Where do i want to write Response.Redirect in my code.
Like this.

Response.Redirect("EventScheduleDetails.aspx?EventID=" + EventID);

I already mentioned my code above...

[)ia6l0 iii replied to Venkatesh Desai on 15-May-12 10:36 AM
Glad that you got the cursor fixed. 

However, you can't open a new window with a link button. You should use a hyperlink control. 
Set the target property of the hyperlink to "_blank". 

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlink.target.aspx 

Hope this helps.