Well im trying to write my own custom control extender but i can’t get the javascript to work
Here you have a empty class:
Imports System.ComponentModel
Imports AjaxControlToolkit
Imports System.Web.UI
Imports System.Web.UI.WebControls
<Assembly: System.Web.UI.WebResource("GuiExtensions.PrintButtonBehavior.js", "text/javascript")>
<Designer(GetType(PrintButtonExtenderDesigner))>
<ClientScriptResource("Sys.Extended.UI.PrintButtonExtender", "GuiExtensions.PrintButtonBehavior.js")>
<TargetControlType(GetType(IButtonControl))> _
Public Class PrintButtonExtender
Inherits ExtenderControlBase
End Class
And here you have the javascript:
Type.registerNamespace('Sys.Extended.UI');
Sys.Extended.UI.PrintButtonExtender = function (element) {
Sys.Extended.UI.PrintButtonExtender.initializeBase(this, [element]);
}
Sys.Extended.UI.PrintButtonExtender.prototype = {
initialize: function () {
Sys.Extended.UI.PrintButtonExtender.callBaseMethod(this, 'initialize');
var element = this.get_element();
this._clickHandler = Function.createDelegate(this, this._onClick);
$addHandler(element, "click", this._clickHandler);
},
dispose: function () {
$removeHandler(this.get_element(), "click", this._clickHandler);
this._clickHandler = null;
Sys.Extended.UI.PrintButtonExtender.callBaseMethod(this, 'dispose');
},
_onClick: function () {
alert("Test");
return false;
}
}
Sys.Extended.UI.PrintButtonExtender.registerClass('Sys.Extended.UI.PrintButtonExtender', Sys.Extended.UI.BehaviorBase);
The problem here is that _onClick is never called when some one is clicking the button i assigned the extender to.. i have verified that “this.get_element();” returns the correct element but i have no luck getting the _onClick function to run.
So far i have hacked this together by looking at the source from codeplex but no success!
change the type this._onClick
this._clickHandler = Function.createDelegate(this, this._onClick);
to
this._clickHandler = Function.createDelegate(this, this._clickCallback);
hope this will get results 🙂