Lions Den

The Code and Times of Hanan Schwartzberg

About Hanan | Hanan's CV | Contact Hanan

September 10, 2009

CalendarExtender Plus 1.0.2.0

Click Here to download the latest version of CalendarExtender Plus and documentation.

The CalendarExtender Plus is a modification of the calendar extender that ships as part of the Ajax Control Toolkit. There are two main features added to the control. First, you can limit the selectable dates to a specified date range. Second, there is now the option to show an alternate header. The new header includes two DropDown Lists, one to select the month and one to select the year.

(more…)

June 16, 2009

Introducing CalendarExtender Plus

Maximum Date - May 15th, 2009
Click Here to download the latest version of CalendarExtender Plus and documentation.

The CalendarExtender Plus is a modification of the calendar extender that ships as part of the Ajax Control Toolkit. There are two main features added to the control. First, you can limit the selectable dates to a specified date range. Second, there is now the option to show an alternate header. The new header includes two DropDown Lists, one to select the month and one to select the year.

The available dates can be limited using the MaxDate and MinDate properties.

<cc1:CalendarExtenderPlus runat="server" ID="cepExample" 
    TargetControlID="txtExample" 
    MaximumDate="01/01/2009" MinimumDate="5/15/2009 />

Setting the ShowDdlHeader to true will show the heading with dropDownLists to select the month and year.

<cc1:CalendarExtenderPlus runat="server" ID="cepHeaderExample" 
    TargetControlID="txtExample" ShowDdlHeader="true" />

DropDownList

The Calendar Extender Plus has a few other enhancements, including the ability to show or hide the arrows in the heading to move back and forth a month, and a property to show or hide today’s date at the bottom of the calendar.

Since the CalendarExtender Plus is a modification of the standard extender it has all the properties and functionality of the original. It can be skinned using the normal css, and automatically fills the textBox with no need for additional javascript.

The CalendarExtender Plus is free to download, use, and distribute with your project. Any feedback is greatly appreciated!

June 7, 2009

ComboBox ClientSide onChange Event

Filed under: Ajax Control Toolkit,ASP.NET,C#,Client Side — Tags: , , , , , , — Hanan Schwartzberg @ 4:57 pm

The Issue

The comboBox has a couple of server side events to deal with field changing.

  • OnSelectedIndexChanged
  • OnTextChanged

How can we catch the comboBox changing on the client side?

The Solution

Without access to these function on the client side, we need to use the client side events of the textBox that is contained within the comboBox. As with any textBox this one also has the onChange event, but the event does not run when the text was changed and the focus moved to another field. There are a few options:

  • onKeyPress
  • onKeyUp
  • onBlur

The problem with onKeyPress is when it gets to the javascript function the value of the textBox is has not changed yet, leaving onKeyUp and onBlur. While onKeyUp will give the desired effect when the user presses a key on the keyboard, part of the point of a comboBox is the ability to use the mouse, which will not be captured by this event, leaving onBlur as the remaining option. It’s still not perfect, since the event won’t run until the focus is moved off the comboBox, but it appears to be the best option. In some cases you may want to use both onKeyUp and onBlur to get the best of both events, but be careful because when the user uses the keyboard and the moves the focus your event will run twice.

In the example below I have a comboBox named cmbExample and a javascript function that accepts the textBox calling it as a parameter, cmbExample_OnBlur(textBox). I add the onBlur event to the textBox in the Page_Load method in the code behind.

protected void Page_Load(object sender, EventArgs e)
{
    TextBox textBox = cmbExample.FindControl("TextBox") as TextBox;
 
    if (textBox != null)
    {
        textBox.Attributes.Add("onBlur", "cmbExample_OnBlur(this);");
    }
}

June 3, 2009

AjaxControlToolkit ComboBox “Invalid argument.”

Filed under: Ajax Control Toolkit,ASP.NET,Client Side — Tags: , , , , , — Hanan Schwartzberg @ 12:03 pm

The Control

Microsoft recently released version 3.0.30512 of the AjaxControlTookit, available here. One of the new controls is the ComboBox, which “provides a DropDownList of items, combined with TextBox.”

The Issue

Placing the ComboBox in a container that has the style attribute “display: none;” throws the error “Invalid argument.” This is true if the container is a panel with the attribute set explicitly, or a different container such as a TabPanel that implicitly has the display attribute set to none when it is not shown.

(more…)

Home | Site Design | Banner Design | Code Den | Offsite Posts | Downloads | Photography | About Hanan | Hanan's CV | Contact Hanan
Copyright © 2009 Hanan Schwartzberg. All rights reserved.