Return values from a dialog called from inside an user control

2 posts, 0 answers
  1. Uwe
    Uwe avatar
    4 posts
    Member since:
    Feb 2011

    Posted 09 May 2011 Link to this post

    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


  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4713 posts

    Posted 12 May 2011 Link to this post

    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.

Back to Top