open radWindow in Grids event

6 posts, 0 answers
  1. Abhi Shinde
    Abhi Shinde avatar
    56 posts
    Member since:
    May 2010

    Posted 04 Dec 2011 Link to this post

    Hi,
    My radwindow is inside userControl named "showDetails.ascx" and that same usercontrol I have a grid.
    In code behind of " "showDetails.ascx" On "grv_OnItemCommand" I need to open RadWindow Without page referesh.

    showDetails.ascx
    <telerik:RadWindowManager runat="server" ID="RadWindowManager1">
        <Windows>
            <telerik:RadWindow ID="radWinInvoiceDetails" runat="server" ShowContentDuringLoad="false"
                Width="400px" Height="400px" Title="Invoice Details" DestroyOnClose="true"
                Behaviors="Default">
                <ContentTemplate>
                    <uc:MakePaymentControl ID="AnotherControl" runat="server" />
                </ContentTemplate>
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
     
     
     
    <grid code----
    <telerik:GridTemplateColumn HeaderText="Status">
                                        <ItemTemplate>
    <asp:LinkButton ID="lnkStatus" runat="server" Text="Pay" CommandName="pay" CommandArgument='<%# Eval("PaymentID") %>'></asp:LinkButton>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>

    ShowDetails.ascx.cs
    protected void grid_OnItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
            {
                if (e.CommandName == "pay")
                {
                    string invoiceID = e.CommandArgument.ToString();
                    ucMakePaymentControl.BindInvoiceDetails(Convert.ToInt64(invoiceID));
                    radWinInvoiceDetails.VisibleOnPageLoad = true;
                }
            }

    How can i open Radwindow on clientside/ without page refresh.
    Thanks
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Dec 2011 Link to this post

    Hello,

    One suggestion to achieve this scenario is you can add OnClientClick event of LinkButton and then open the window.

    JS:
    <script type="text/javascript">
       function OnClientClick()
       {
        var wd = window.radopen(null, "RadWindow1");
       }
    </script>

    Thanks,
    Princy.
  3. Abhi Shinde
    Abhi Shinde avatar
    56 posts
    Member since:
    May 2010

    Posted 05 Dec 2011 Link to this post

    Hi prince,

    Please look at my scenario. First I want to fill "<uc:MakePaymentControl ID="AnotherControl" runat="server" />"  which is in RadWidow.
    So that is why i need to pass commandArgument on OnItemComman event.
    protected void grid_OnItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
            {
                if (e.CommandName == "pay")
                {
                    string invoiceID = e.CommandArgument.ToString();
                    ucMakePaymentControl.BindInvoiceDetails(Convert.ToInt64(invoiceID));
                    //radWinInvoiceDetails.VisibleOnPageLoad = true;
                }
            }


    Is there any solution?
  4. Marin Bratanov
    Admin
    Marin Bratanov avatar
    5243 posts

    Posted 06 Dec 2011 Link to this post

    Hello Abhi,

    If you need the server-side functionality I can suggest two options for this scenario:

    1) follow the instruction from the following sticky thread to open the RadWindow from the code-behind: http://www.telerik.com/community/forums/aspnet-ajax/window/opening-radwindow-from-the-server.aspx.

    OR

    2) use AJAX - the button will perform an AJAX request that will update only the grid and will not dispose the RadWIndow or antything else that needn't be updated from the page, thus you can use its client-side click event to open the RadWindow as Princy suggested in his reply, just without cancelling the postback.


    Best wishes,
    Marin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  5. Abhi Shinde
    Abhi Shinde avatar
    56 posts
    Member since:
    May 2010

    Posted 12 Dec 2011 Link to this post

    Hi Marin,

    I tried 1st scenario but page is refreshing,
    But when I tried to use asp:update panel in grid button click is not working.
    Please see the code

    page.Ascx
    <telerik:RadWindowManager runat="server" ID="RadWindowManager1">
        <Windows>
            <telerik:RadWindow ID="radWinInvoiceDetails" runat="server" ShowContentDuringLoad="false"
                Width="400px" Height="400px" Title="Invoice Details" DestroyOnClose="true" Behaviors="Default">
                <ContentTemplate>
                    <uc:MakePaymentControl ID="ucMakePaymentControl" runat="server" />
                </ContentTemplate>
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
    .
    .
    .
    .
    .

    <
    telerik:GridTemplateColumn HeaderText="Status">
                                   <ItemTemplate>
                                       <asp:LinkButton ID="lnkStatus" runat="server" Text="Pay" CommandName="pay" CommandArgument='<%# Eval("ID") %>'></asp:LinkButton>
                                   </ItemTemplate>
                               </telerik:GridTemplateColumn>

    page.Ascx.cs
    protected void grvInvoice_OnItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
           {
               if (e.CommandName == "pay")
               {
                   string invoiceID = e.CommandArgument.ToString();
                   ucMakePaymentControl.BindInvoiceDetails(Convert.ToInt64(invoiceID));
                   string script = "function f(){$find(\"" + radWinInvoiceDetails.ClientID + "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
                   ScriptManager.RegisterStartupScript(this, this.GetType(), "key", script, true);
     
               }
           }



    I am waiting...
  6. Marin Bratanov
    Admin
    Marin Bratanov avatar
    5243 posts

    Posted 13 Dec 2011 Link to this post

    Hello Abhi,

    Please note that when you click this button in the grid it will perform a postback which is the page refresh you are referring to. I assumed you are aware of this since you are already handling the grid's event in the code-behind.

    As for using an update panel - things seem to be working fine on my end. I am also attaching my test page as a reference here. Please compare it with yours and try to locate any major differences in the setup. The only change I made is using Page instead of this in the RegisterStartupScript() method as it is better when using user controls.

    All the best,
    Marin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top