Open radwindow from codebehind event in radgrid

5 posts, 0 answers
  1. paaland
    paaland avatar
    17 posts
    Member since:
    Jun 2009

    Posted 20 Jun 2012 Link to this post

    I have a radgrid that is databound using an object data source.
    The grid has a GridTemplateColumn with an asp:ImageButton in it. This button has a click-event that does some business logic and then is supposed to open a new window with some calculated result.

    I've tried Page.ClientScript, RadScriptManager.RegisterStartupScript, and RadScriptManager.GetCurrent(this.Page).RegisterDataItem.
    I even tried to create a new RadWindow via code-behind, but nothing happens.

    public void editLink_Click(object sender, EventArgs e)
    {
      string script = "alert('hello');";
     
      //This does not work
      RadScriptManager.RegisterStartupScript(this, GetType(), "test", script, true);
     
      //This does not work
      RadScriptManager.GetCurrent(this.Page).RegisterDataItem(this, "javascript:" + script);
                    
      //This does not work
      RadWindow newWindow = new RadWindow();
      newWindow.NavigateUrl = "http://www.telerik.com";
      newWindow.VisibleOnPageLoad = true;
      ((AlarmLogMaster)this.Page.Master).WindowManager.Windows.Add(newWindow);              
    }

    The master-page exposes the RadWindowsManager via the WindowManager property. The code is run since I can set a break-point in the click event.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Jun 2012 Link to this post

    Hello,

    Here is the sample code that I tried which worked as expected.
    C#:
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
    RadWindow newWindow = new RadWindow();
    newWindow.NavigateUrl = "http://www.telerik.com";
    newWindow.VisibleOnPageLoad = true;
    RadWindowManager mng = (RadWindowManager)Master.FindControl("AlarmLogMaster");
    mng.Windows.Add(newWindow);              
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. paaland
    paaland avatar
    17 posts
    Member since:
    Jun 2009

    Posted 21 Jun 2012 Link to this post

    Your exsample is more or less the same as the one i tried. I have however found a way and that was to wrap the whole RadGrid in a RadAjaxPanel and then use radAjaxPanel1.ResponseScripts.Add() method to add a radopen script that opens the dialog.
  5. Vinay
    Vinay avatar
    1 posts
    Member since:
    Sep 2014

    Posted 02 Mar in reply to paaland Link to this post

    Paaland same problem i am also face 
    Do you have any answer 
    The whole RadGrid in a RadAjaxPanel and then use radAjaxPanel1.ResponseScripts.Add() method to add a radopen script that opens the dialog
  6. Eyup
    Admin
    Eyup avatar
    3007 posts

    Posted 07 Mar Link to this post

    Hello Vinay,

    You can try to use the RegisterStartupScript method to achieve this requirement:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/window/troubleshooting/opening-from-the-server

    Also, you can examine the samples provided in the following post:
    http://www.telerik.com/forums/context-menu---open-a-pop-up#Qe9fJgzWrE2DhYPWX7OkCQ

    Also, please temporarily disable any AJAX on the page if present (RadAjaxManager, RadAjaxPanel, UpdatePanel, etc.) and enable your script debugger (FireBug or F12) to see whether there are any script or server errors interfering and whether the functionality will work properly.


    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017