This is a migrated thread and some comments may be shown as answers.

Return values from a dialog called from inside an user control

1 Answer 200 Views
Window
This is a migrated thread and some comments may be shown as answers.
Uwe
Top achievements
Rank 1
Uwe asked on 09 May 2011, 08:07 PM
Hi,
I'm fighting with a problem for over one week that sounds very easy:
Click a button, open a modal dialog with a grid, select a row of this grid and return the selected value back to the textbox of the parent form.
I started with a demo from telerik demos section (http://demos.telerik.com/aspnet-ajax/window/examples/dialogreturnvalue/defaultcs.aspx).
This works fine when the textbox and button are placed directly on a form. But I need them inside an user control. This is because I need the popup functionality more than once on one webform. It should be a kind of standard search that i can use for different textboxes.

The problem is that when returning the value to the parent page javascript does not know which user control (textbox) called the dialog and writes the returned value to the textbox of the first user control.

Can anybody please help me to solve that problem? Maybe with an running example? :-)

Thanks,
Uwe


1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 12 May 2011, 11:26 AM

Hello Uwe,

Passing values between user controls is a general ASP.NET task, which is the developer's responsibility, and is not directly related to the Telerik Controls.

Yet what I would suggest is that when you open the RadWindow you pass a reference to the desired element which you obtain from within your user control so that you can use it freely in the RadWindow. For that purpose you can use the RadWindow's argument as described in the following article: http://demos.telerik.com/aspnet-ajax/window/examples/dialogreturnvalue/defaultcs.aspx.

For your convenience I have created and attached a simple page illustrating the approach. Some points of interest:

  • The names of the JavaScript functions in each user control need to be unique so that each button calls the function from its user control, not from the last
  • I added the client click event handler to the button in the code-behind since it also requires server-side coding to get the unique id
  • For the sake of simplicity I have hardcoded the value, but you can use your own existing logic here easily


All the best,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Window
Asked by
Uwe
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or