Wrox Programmer Forums
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics 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 May 27th, 2007, 01:59 AM
Authorized User
Join Date: Nov 2005
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to x_ray
Default Calendar Control Postback


I have a calendar control that I am using on a page, but I need to disable its postback,i.e. whenever a user click on a date, I have javascript function that is attached to the cell of this date that executes, but although I disabled the date the user keeps on clicking and performing a postback.

I read an article in the .Net 1.1 forum (TOPIC_ID=27237), but they are not providing sufficient details and it is about 1.1 version (not DayRendered event, all what I have is a DayRender event in 2.0)

When I implemented this event, I noticed that its rendering the control inside the cell as a LiteralControl, but with no child controls (I was aiming to locate an anchor and modify its href).

Does anyone have an idea about how to disable the calendar postback???
Note: I am using C#.
Thanks in advance,

Old May 27th, 2007, 03:56 AM
Authorized User
Join Date: Nov 2005
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to x_ray

Hey Guys,

I followed up the instructions on above mentioned topic, and found a solution (I think :), it is working for me AFAIK ). Here the code for the code manias out there, and I urge you to always provide the code since it makes things easier.
HyperLink datelink = new HyperLink(); 
datelink.Target = "#";//instead of having to loop for in JS :)
datelink.Style.Add(HtmlTextWriterStyle.Cursor, "Hand");
datelink.Text = e.Day.DayNumberText;
datelink.ID = "day_" + e.Day.Date.Month.ToString() + "_" + e.Day.Date.Day.ToString();
The above should go in the DayRender Event handler.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation control and postback Chaotix ASP.NET 1.0 and 1.1 Basics 0 July 18th, 2006 12:31 PM
Calendar Control with Tab Control Slicemahn Access 1 June 12th, 2006 10:35 PM
catching the control that causes postback ACE2084 ASP.NET 1.0 and 1.1 Basics 1 February 22nd, 2005 04:00 PM

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