In this post I Explained how to interact between two user controls and now I am going to explain, Retrieving Selected value from user control in the modal popup using Delegates, but i am not explaining about delegates.Now doubleclick on ListBox1 and select AutoPostBack="true" in the properties.
- Create a New Website in VS 2008 / 2010, name it as you like. (File -> New -> Web Site)
- In the Solution Explorer Right Click on the web site you created and press Add New Item
- Select WebUserControl and name it as you like, in my case UcOwn.ascx
- In the user control add a panel and within the panel add UpdatePanel
- With in the UpdatePanel add ModalPopupExtender, hiddenfield, ListBox, label and 3 Buttons for loading items in the list box, ok button and cancel button.
- hiddenfield = hf1
- label = lblselectedValue and Text="Not Yet Selected"
- button1 = btnload for loading items to the ListBox1 and Text="Load Items"
- button2 = btnOkPopup Text="BtnOk"
- button3 = btnCancelPopup Text="BtnCancel"
- remaining controls as default
code behind looks like this as shown in the image below
Up to now we completed usercontrol. Now in the Default.aspx page add ToolkitScriptManager as shown below
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
Now goto design view of the default page and drag and drop the usercontrol you created.
Note : If you do not go to design view of the page usercontrol is not registered and you need to register manually and even you can see the link of the usercontrol.
Now add atextbox and button in default.aspx page
and thats IT.
See the Screen Shots below.....
Download the code from Here.