Wednesday, March 28, 2012

Multiple Popups using popcontrol extender

In the previous version of the ajax control toolkit I could reference multiply popups with one control. Ie on the page I have one calendar and 10 different textboxs which call popup the same calendar control. This would then run the selection changed code for the calendar and commit the date to which ever control had opened the popup. ie

ProtectedSub Date_Selector_SelectionChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles Date_Selector.SelectionChanged

Date_Popup.Commit(Date_Selector.SelectedDate.ToShortDateString)

EndSub

However with the new version of the toolkit you have to have a different popup for each textbox. So when it goes into the date selector section how do I chosse the right popup to send the data back to.

I think the test case in ToolkitTests\Manual\Repeater.aspx shows how to do this the new way.

I had asimilar problemTed Glaza helped me solve. I have two textboxes with a popupcontrolextender attached to each, both of which call a single calendar, cal1. Some code snippits:

Code behind:

Protected Sub Cal1_SelectionChanged(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Cal1.SelectionChangedDim tmppceAs AjaxControlToolkit.PopupControlExtender tmppce = AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page) tmppce.Commit(Cal1.SelectedDate)End Sub

Declaration on the top of the .aspx page:

<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act" %>
 
Everything works as expected. One thing to note, I'm running a self-compiled version of the toolkit - 9854. 

No comments:

Post a Comment