Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Window > How to open RadWindow when user clicked on ASP.NET button
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered How to open RadWindow when user clicked on ASP.NET button

Feed from this thread
  • mbro87 avatar

    Posted on May 22, 2011 (permalink)

    Hello,

    I have my asp.net button defined that:

    <asp:Button ID="MYID" Text="0" runat="server" />


    And in CB I have assigned to object the attributes property "OnClick" in this way:

    MYID.Attributes.Add("OnClick", "return ShowTCDetails()");

    "ShowTCDetails()" is my JS function and works fine.
    Now I wanna to open RadWindow, but when call my JS function:

    function ShowTCDetails(IdDevice, IdArm1, IdArm2, rowIndex) {

    window.radopen("mywindow.aspx", "ModalWin");
    return false;
    }


    the system cannot open radwindow.
    Any ideas?

  • Posted on May 23, 2011 (permalink)

    Hello Mbro87,

    I tried the same scenario and it worked as expected at my end. One suggestion is to attach the OnClientClick from aspx.

    aspx:
    <telerik:RadWindowManager ID="window1" runat="server">
      <Windows>
         <telerik:RadWindow ID="RadWindow1" runat="server">
         </telerik:RadWindow>
      </Windows>
    </
    telerik:RadWindowManager>
    <asp:Button ID="Button1" runat="server" OnClientClick="ShowTCDetails();return false;" Text="Button" OnClick="Button1_Click" />

    Javascript:
    <script type="text/javascript">
      function ShowTCDetails(IdDevice, IdArm1, IdArm2, rowIndex)
      {
        window.radopen("mywindow.aspx", "ModalWin");
        return false;
      }
    </script>

    Check the following documentation which explains how to open a RadWindow object from client-side.
    Opening Windows.

    Thanks,
    Princy.

  • Svetlina Anati Svetlina Anati admin's avatar

    Posted on May 23, 2011 (permalink)

    Hello mbro87,

     Actually, you do not really have to use declarative approach and OnClientClick but you can achieve what you need by using dynamic code behind and onclick attribute as you initially intended if you make sure you cancel the postback. The RadWindow is entirely created and shown on the client and when you initiate a postback it gets destroyed and recreated and it should be reopened.

    Possible solutions I suggest are the following:

    1) Cancel the postback by returning false explicitly here, too, due to browser specifics:

    MYID.Attributes.Add("OnClick", "ShowTCDetails(); return false;");

    or

    2) Wrap the button in an update panel but do not put the window manager inside it. - this will transform the postback in an ajax request which will lead to better user experience and will not destroy the opened RadWindow.

    Please, test my suggestions and let me know how it goes.

    Best wishes,
    Svetlina
    the Telerik team

    Consider using RadControls for ASP.NET AJAX (built on top of the ASP.NET AJAX framework) as a replacement for the Telerik ASP.NET Classic controls, See the product support lifecycle here.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Window > How to open RadWindow when user clicked on ASP.NET button