Welcome to Bilal Haidar [MVP, MCT] Official Blog Sign in | Join | Help

Create Client Controls in ASP.NET 2.0 AJAX 1.0 Extensions

I kindly invite you to check my latest article on the www.aspalliance.com:

Create Client Controls in ASP.NET 2.0 AJAX 1.0 Extensions

In this article Bilal Haidar demonstrates how to create a basic client control Grid with Edit/Delete/Create functionalities with ASP.NET 2.0 AJAX 1.0 Extensions.

Hope you will enjoy reading it!
Regards
 

 

 

Published Tuesday, June 19, 2007 10:47 AM by BilalHaidar [MVP]

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Create Client Controls in ASP.NET 2.0 AJAX 1.0 Extensions

Hi Bilal,

Thanks for a brilliant post. I was working though the sample, learn't a lot. I found a bug which occurs when you try to create the "edit control" the second time.

The reason why I think we are getting the error is because when you bind the control and call RecordControl.initializeBase(this, [element]);

where element is the DIV and this is the control

After this statement gets executed, element.control has a reference to this.

I checked it with Object.getType(element.control) and it is the control.

So when it comes the second time it throws an error. Why I don't know but found an old blog of implementation at http://west-wind.com/WebLog/posts/8282.aspx#Feedback

Sys.UI.Control = function Sys$UI$Control(element) {

   /// <param name="element" type="Sys.UI.DomElement"></param>

   var e = Function._validateParams(arguments, [

       {name: "element", type: Sys.UI.DomElement}

   ]);

   if (e) throw e;

   if (typeof(element.control) != 'undefined') throw Error.invalidOperation(Sys.Res.controlAlreadyDefined);

   Sys.UI.Control.initializeBase(this);

   this._element = element;

   element.control = this;

   this._oldDisplayMode = this._element.style.display;

   if (!this._oldDisplayMode || (this._oldDisplayMode == 'none')) {

       this._oldDisplayMode = '';

   }

}

Looks like the constructor of Sys.UI.Control checks for the element.control to be undefined.

So I just added a small code in the constructor which seems to have done the trick

AjaxControls.RecordControl = function (element) {

if (element.control)

   element.control.dispose();

   AjaxControls.RecordControl.initializeBase(this, [element]);

   this._dataSource = null;

   this._clickDelegate = null;

}

This would dispose of the previous control attached to the DIV.

Let me know in your status as MVP, Am I on the right path.

Regards

Deepak Chawla

deepak_chawla@hotmail.com

Monday, July 09, 2007 5:49 PM by Deepak Chawla

Leave a Comment

(required) 
required 
(required)