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

Open radwindow from codebehind event in radgrid

4 Answers 164 Views
Grid
This is a migrated thread and some comments may be shown as answers.
paaland
Top achievements
Rank 2
paaland asked on 20 Jun 2012, 01:27 PM
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.

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Jun 2012, 04:58 AM
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.
0
paaland
Top achievements
Rank 2
answered on 21 Jun 2012, 07:39 AM
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.
0
Vinay
Top achievements
Rank 1
answered on 02 Mar 2016, 08:15 AM
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
0
Eyup
Telerik team
answered on 07 Mar 2016, 08:40 AM
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
Tags
Grid
Asked by
paaland
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
paaland
Top achievements
Rank 2
Vinay
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or