Facing a problem while opening a radwindow dynamically

5 posts, 0 answers
  1. Ram
    Ram avatar
    49 posts
    Member since:
    Feb 2009

    Posted 15 Jul 2009 Link to this post

    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,

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Jul 2009 Link to this post

    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.
  3. John Davis
    John Davis avatar
    119 posts
    Member since:
    Apr 2007

    Posted 17 Nov 2009 Link to this post

    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

  4. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 17 Nov 2009 Link to this post

    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.
  5. John Davis
    John Davis avatar
    119 posts
    Member since:
    Apr 2007

    Posted 17 Nov 2009 Link to this post

    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
Back to Top