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

Facing a problem while opening a radwindow dynamically

4 Answers 148 Views
Window
This is a migrated thread and some comments may be shown as answers.
Ram
Top achievements
Rank 1
Ram asked on 15 Jul 2009, 04:49 PM
Hi,

My scenarion is like this, I need to open a radWindow on click of a Imagebutton which is in radGrid dyanamically (server side)

 

for that I written code to open radwindow in ItemCommad event of radGrid

 

my problem here is, when I click first time on a Image in radgrid,the debugger passes through the code, the page refreshes and window is added to controls (here the window doesn't open) and when I click on the same image second time the window opens (because the winow is already added to the controls, here the debugger won't go into the code again )

 

I want to open the window on single mouse click of a image (I want to do this on item command event because I need to pass some value to radwindow on click of a imagebutton), How can I achieve this?

muy code is as follows

protected void rdgSystemGrid_ItemCommand(object source, GridCommandEventArgs e)

 

        {

           

 

                if (e.CommandName == "Comments")

                {

                    Telerik.Web.UI.GridDataItem item = e.Item as Telerik.Web.UI.GridDataItem;

                     

                        ImageButton imgComment = (ImageButton)item["comments"].FindControl("imgComments");

                        ShowWindowPopUp(imgComment                   

                }

           

 

private void ShowWindowPopUp(ImageButton imgComment)//, string systemId)

        {

           

            RadWindow window = new RadWindow();

            window.EnableEmbeddedSkins = false;

            window.Title = "Add Comments";

            window.Skin = "Default";

            window.ShowContentDuringLoad = false;

            window.VisibleStatusbar = false;

            window.ReloadOnShow = true;

            window.Behaviors = WindowBehaviors.Reload | WindowBehaviors.Close | WindowBehaviors.Move;

            window.Modal = true;

            window.Width = Unit.Parse("500px");

            window.Height = Unit.Parse("450px");

            window.OpenerElementID = imgComment.ClientID;

             this.Controls.Add(window);

            window.NavigateUrl = @"~/obt/Dashboard/Comments.aspx";

         

 

        }

 

<telerik:GridTemplateColumn UniqueName="comments" HeaderText="Comments" ItemStyle-Width="200px" >

                    <ItemTemplate>

                        <asp:ImageButton ID="imgComments" CommandName="Comments" runat="server" ImageUrl="/comments.gif "/>

                    </ItemTemplate>

                </telerik:GridTemplateColumn>

 

Thanks,

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Jul 2009, 08:03 AM
Hello Ram,

Try setting VisibleOnPageLoad property of RadWindow to True and see whether that makes any difference.

private void ShowWindowPopUp(ImageButton imgComment)//, string systemId) 
{
      RadWindow window = new RadWindow(); 
          . . . 
      window.Height = Unit.Parse("450px"); 
      window.VisibleOnPageLoad = true
      this.form1.Controls.Add(window); 
          . . . 
}  

Thanks
Shinu.
0
John Davis
Top achievements
Rank 2
answered on 17 Nov 2009, 01:11 PM

I want to open a radwindow when user clicks a button ("Select") in a radgrid.

Is there a complete example available?

I don't understand it very well, but I tried to follow the example here:
http://www.telerik.com/community/forums/aspnet-ajax/window/facing-a-problem-while-opening-a-radwindow-dynamically.aspx

When I try it without using window.OpenerElementID = btnSelect.ClientID
then the window does not open.

When I try these commands
         Dim item As GridDataItem = CType(e.Item, GridDataItem)

            Dim btnSelect As Button = CType(item("Select").FindControl("Select"), Button)

then btnselect is null

Here is the code to open the window:

  Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
        If e.CommandName = "Select" Then
            'http://www.telerik.com/community/forums/aspnet-ajax/window/facing-a-problem-while-opening-a-radwindow-dynamically.aspx
            Dim PersonID As String = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("PersonID").ToString
            'If permission_ID = 1 or 2 do NOT display link to scs
            Dim item As GridDataItem = CType(e.Item, GridDataItem)

            Dim btnSelect As Button = CType(item("Select").FindControl("Select"), Button)

            ShowWindowPopUp(btnSelect)
        End If
    End Sub
    Private Sub ShowWindowPopUp(ByVal btnSelect As Button)
        'Private Sub ShowWindowPopUp()
        Dim window As New RadWindow()
        window.EnableEmbeddedSkins = False
        window.Title = "Add Comments"
        window.Skin = "Default"
        window.ShowContentDuringLoad = False
        window.VisibleStatusbar = False
        window.ReloadOnShow = True
        window.Behaviors = WindowBehaviors.Reload Or WindowBehaviors.Close Or WindowBehaviors.Move
        window.Modal = True
        window.Width = Unit.Parse("500px")
        window.Height = Unit.Parse("450px")
        window.OpenerElementID = btnSelect.ClientID
        window.VisibleOnPageLoad = True
        Me.Controls.Add(window)
        window.NavigateUrl = "DisplayPicture.aspx"
    End Sub

0
Georgi Tunev
Telerik team
answered on 17 Nov 2009, 01:38 PM
Hi John,

The RadWindow should be added either to the form's Controls collection or (recommended) to a standard placeholder control in that form.
Another option is to use the client-side API of the controls and to open the window with JavaScript as shown here.

All the best,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
John Davis
Top achievements
Rank 2
answered on 17 Nov 2009, 02:28 PM
Georgi
Thank you for replying promptly.
I found this example that works well:

http://www.telerik.com/community/forums/aspnet-ajax/window/how-to-use-radwind-from-server-side-code.aspx


Steve
Tags
Window
Asked by
Ram
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
John Davis
Top achievements
Rank 2
Georgi Tunev
Telerik team
Share this question
or