How to instantiate an AJAX control inside a custom AJAX control


I want to include a ToggleButton control inside a custom AJAX control.  How can I instantiate an instance of the ToggleButton in my Javascript?  If I create an instance of the ToggleButton in C# code, how could the Javascript pick it up?

 Thank you,


2/10/2009 10:36:25 AM 17816 articles. 1 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 58
Get it on Google Play
Get it on Apple App Store

2/10/2009 10:39:52 PM

this._pin = $create(AjaxControlToolkit.ToggleButtonBehavior, { 'id': this.get_id() + "_ToggleButton", 'CheckedImageUrl': 'images/collapse.jpg', 'UncheckedImageUrl': 'images/expand.jpg', 'ImageWidth': 15, 'ImageHeight': 15 }, null, null, null);

I tried to create the object in initialize() method of my custom control.  I read the link on MSDN which says the object will not be initialised properly in this way, but I saw examples in the AJAXcontroltoolkit such as DropDownBehavior, etc initialise PopupBehavior and HoverBehavior in the initialize() method.  I followed the toolkit, but it gives me the following error:

Microsoft JScript runtime error: Sys.ArgumentUndefinedException: Value cannot be undefined.
Parameter name: type

It seems my class doesn't find the ToggleButton.  I use vs2008 .Net3.5.  My custom control is created in a seperate project and it inherits the extender base class of the AJAXControlToolKit.  I don't think the problem is caused by referencing otherwise the rest features of my custom control won't work since the begining. 

Any ideas?  Thanks,


2/11/2009 3:09:09 PM

I resolved this by creating an instance of the ToggleButton, which is in fact a checkbox attached with a ToggleButton behavior, in the code-behind.  Then pass the clientID of the checkbox to the javascript class of the custom control.  I think this solution will come handy in any cases where an ajax control object is demanded in another AJAX control.  BTW, I also created a Panel object to contain the checkbox for easy positioning in the javascript, in which case, the Panel object's clientID is passed onto the javascript


2/12/2009 3:05:54 PM

Similar Artilces: controls used in custom composite controls?
I am creating an events calendar that uses the accordion to display the events for the selected day.  The problem I'm having is that the accordion is not responding to any client side events.  I would really like to find a good "How to" article for building composite controls that incorporate an control like the accordion....

Custom controls having Ajax Controls
I have a custom control called ModalUpdateProgress. I don't want to narrow down the topic to why do I have to build it or something else. The point of control is to lock a sceen while postback happens so it is a conjunction of Update Progress and Modal Popup Extender. I had no problem to build a control similar to Update Progress. Then I add Modal Popup Extender:   if(typeof(undefined) != typeof(AjaxControlToolkit)) if(typeof(undefined) != typeof(AjaxControlToolkit.ModalPopupBehavior)) { this._modalPopupBehavior = $create(AjaxControlToolkit.ModalPopup...

How to find control inside ajax controls
1)First i have Tab Panel (tbPanel) 2)have a Grid View inside the Tab panel (grdView) 3) I have a panel with the text box (txtTest)   How to find the control of the text box      Try it through finding it through the event on the control the fires it the following example is of a dropdown list that's inside a gridview (grid view has a couple of update panels in it and thats why there are more than one parent). int selectedRow = ((sender as ListBox).Parent.Parent.Parent as GridViewRow).RowIndex;  this is on the SelectedIndexChanged of that dropdown &nbs...

Wizard control inside an AJAX ModalPopUp control?
The idea would be really great, but is this possible?as the wizard causes postback every time the "next" button is clicked, and therefore makes the entire modal popup go away.Is there a way to combine these two controls such that the modal popup does not go away until the wizard is complete?  If so can someone provide me with some sort of example?thanks! aw jeez edith..... NuJoizey, You could place an update panel inside your popup panel, and place your wizard control inside the update panel.  This should give you the behavior you want. JamesJames Ashley, Magenic...

TargetControlID of AJAX Calendar Control cannot be found when in an AJAX tab control
Hello, I have a caledar control tied to a text box within a tab panel control as below.   <cc1:TabContainer ID="TabContainer1" runat="server" Width="100%"> <cc1:TabPanel ID="TabPanel4" runat="server" HeaderText="Class Details"> <ContentTemplate > <table style="width: 747px"> <tr> <td style="width: 136px"> </td> <td style="width: 100px; text-align: right;"> ...

AJAX: which is better more controls inside one update panel or few controls inside more update panels
hi in form that have many controls , gridview , formview, buttons, textboxes, etc. which is better, put them all in one update panel, or few controls in more update panels? i.e. gridview , formview, buttons, textboxes all in one update panel or gridview in update panel, formview in updat panel, buttons (that text needs to change based on some business rules) in update panel, etc? besides will tables and divs inside update panel affect AJAx performance?! Hi,    Putting too many controls in an update panel will certainly affect the performance. I have certainly faced it. ...

How to enable ajax (Use AJAX Controls) in my Web Control Library project
I have VS2005 with Ajax extended controls.   i have created a Web Control Library project, but i want to use ajax controls. is it possible.   I do not want to create a ajax enabled web site, but looking if any possible in my web control library project.   Please let me know and thanks in advance. D Hi, Yes. If you want to create User Control which contains a lot of web controls and Ajax control, you can create an User Control with Ajax Control to achieve it. If you want to create a Custom Control with Ajax, I suggest you build a new Extender. Please check the...

AJAX Control how to drop a control inside any draggable panels
Hi all, Using an AJAX Control, if I have many panels how do I drag and drop one of those inside any of the others? Also I should be able to save the positions.Admin - SysDataNet.comE-Commerce

AJAX Control Toolkit Custom Control/Extender and Scripts
Hello, I was wondering for the support that the AJAX control toolkit gives for creating custom components,does the toolkit support registering both a debug form of a script and a release form of a script for the same server control or extender?  I didn't see any attribute on ClientScriptResource attribute, but my copy may be old.  So is it possible to support multiple scripts using AJAX control toolkit reflection approach for a single server component? Thanks.Brian"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and ...

How do we customize Ajax calendar Control and Ajax Tabbed Panel?
Hi FriendsAm confronting with a very trivial issue of customizing the tabbed panel and the Calendar controls of the Ajax control toolkit. Can anyone give me some ideas of how to customize these as I tried changing the CSS and setting the new css, but all in vain.can anyone help me out with this issue?Thanks Karthik MuthuswamyProgrammer AnalystChennai I tried my own idea. Thanks everyone.Karthik MuthuswamyProgrammer AnalystChennai...

using ajax control toolkit extender in custom control
hi, I need to use the extender in custom server control. I need to use maskeditextender. I find that I can create a maskeditextender object. (in createchildcontrols()) but I cannot achive my goal. (I created a textbox) , I cannot set the TargetControlID to be the ID of the created textbox on code-behind. that means it is useless to  use the extender object on code-behind. and is it impossible to integrate ajax toolkit extenders and asp native controls (e.g. asp:textbox) into one custom server control? thank you very much! Yes you can build controls based on the toolki...

Using ajax control (CollapsiblePanelExtender) in custom server control
 Hi I'm trying to write a server control that contains the collapsiblePanelExtender from the ajax toolkit.  But I have the following error when i try to show this control: Extender control 'ctl00$contentHolder$ctl00$Ant_baseModule1_cpeDemo' is not a registered extender control. Extender controls must be registered using RegisterExtenderControl() before calling RegisterScriptDescriptors(). I have no idea what i must add or change to make it working.  Anyone who has an idea?  Or maybe I'm doing it all wrong? This is my code:   Protected Overrides Sub Render(...

Custom controls called from inside other custom controls???
I'm fairly new to writing controls in ASP.NET so, forgive the I am trying to create a base page class which will call 3 custom controls. This base page class will span across multiple projects hence the reason I am not creating user controls. These 3 custom controls are: 1. TopNav-uses render method to display an HTML table with graphics for top navigation. 2. ImagePairs-uses prerender method to add javascript code to manage what graphic is displayed in TopNav onMouseOver and onMouseOut 3. MgrHeader-uses render method to display an HTML table with s...

Creating Custom Controls With Custom Controls Inside Of Them
Hello, I am trying to create a custom control for creating tabs. The idea is that our designer can just use the control tags to generate the tabs.  The problem that I am running into is that I want to be able to have a custom control that allows any number of child custom controls. So there would be a TabContainer Control, and within that there would be any number of tabs.  The idea is similar to how an asp:DropDown list can have any number of ListItems within them.  Here is my code, any help is appreciated. 1 <!-- TAB CONTAINER -->2 <%@ Control Language=&...

Web resources about - How to instantiate an AJAX control inside a custom AJAX control -

Experimental game [Code] instantiates love of programming
I'm walking through the firehouse in Culver City where a good portion of the games at IndieCade are set up, and then I see what looks like "not ...

Code: Flickr Developer Blog
(Flickr is hiring! Check out our open job postings and what it’s like to work at Flickr .) Web workers are awesome. They’ll change the way you ...

Plato - Wikipedia, the free encyclopedia
– 348/347 BC) was a Classical Greek philosopher , mathematician , student of Socrates , writer of philosophical dialogues, and founder of the ...

Ontology - Wikipedia, the free encyclopedia
This article concerns ontology in philosophy. For the concept in information science, see Ontology (information science) . Not to be confused ...

Cisco patches vulnerabilities in VPN client, security appliances
Networking equipment vendor Cisco Systems released multiple security updates on Wednesday to address vulnerabilities in its AnyConnect Secure ...

Impromptu is an OSX programming language and environment for composers, sound artists, VJ's and graphic artists with an interest in live or interactive ...

Dictionary of Philosophy of Mind - functionalism
functionalism(1) - The view that the physical realization of a functional component is not, in some sense, its essence. Rather, what makes a ...

Ajay Matharu on Web, Technology and Life
Ajay Matharu on ASP.Net, .Net, Javascript, PHP, SQL, CSS, Sharepoint, Web, Technology and Life

Annals of Americus - Notes on Art, Culture & Politics
... I was living in Albany, NY. My friend loaded LAYAR onto his phone and we walked around our neighborhood, watching real estate data instantiate ...

Resources last updated: 12/21/2015 2:42:20 AM