RadWindow as an info box that stays open

6 posts, 0 answers
  1. Paul
    Paul avatar
    4 posts
    Member since:
    Jun 2014

    Posted 09 Jun 2014 Link to this post

    I have an ASP.NET page that loads a table of data and dynamically creates a link button for each row.

    When the user clicks the link button I want to display a RadWindow with some relevant information about the selected row.  This RadWindow will not be modal and therefore the user can continue to scroll through the table.

    The link button on each row is dynamically created and the click event is added at runtime - I have tried both of the following:

    1. Adding an "OnClientClick" and calling a javascript function to display the RadWindow.
    2. Adding a new eventhandler to the Click event.

    Option 1. above then calls a javascript function as follows:

                var oWnd = $find("<%= oRadWindow.ClientID %>");
                oWnd.setUrl(stURL);  // stURL is passed into the function
                oWnd.show();

    The problem with this is that the window displays for about a second and then disappears.  I assume the page is reloading but what could cause this?

    I need my RadWindow to stay visible even on postbacks, any ideas?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 10 Jun 2014 in reply to Paul Link to this post

    Hi Paul,

    Please try the below code snippet to show a RadWindow in LinkButton onClientClick event. After postback the window will not persist that is the expected behavior, for that you have to ajaxify the LinkButton as follwos. 

    ASPX:
    <telerik:RadAjaxManager ID="RadAjaxManger1" runat="server">
    </telerik:RadAjaxManager>
    <telerik:RadWindow ID="RadWindow1" runat="server">
        <ContentTemplate>
            This is an example
        </ContentTemplate>
    </telerik:RadWindow>
    <telerik:RadButton ID="RadButton1" runat="server" Text="PostBack">
    </telerik:RadButton>

    C#:
    LinkButton lbtn = new LinkButton();
    protected void Page_Load(object sender, EventArgs e)
    {
        lbtn.ID = "LinkButton1";
        lbtn.Text = "Open Window";
        lbtn.OnClientClick = "OpenWindow(); return false;";
        form1.Controls.Add(lbtn);
        RadAjaxManger1.AjaxSettings.AddAjaxSetting(RadButton1, lbtn);
    }

    JavaScript:
    function OpenWindow() {
        var win = $find("<%=RadWindow1.ClientID%>").show();
    }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Paul
    Paul avatar
    4 posts
    Member since:
    Jun 2014

    Posted 10 Jun 2014 in reply to Princy Link to this post

    Thanks for the answer, I'll give it a go as soon as I get to work.  Can you explain the following line please:  

    RadAjaxManger1.AjaxSettings.AddAjaxSetting(RadButton1, lbtn);
  5. Paul
    Paul avatar
    4 posts
    Member since:
    Jun 2014

    Posted 10 Jun 2014 Link to this post

    Hello again!

    I'm using RadControls for ASP.NET AJAX Q2 2009 so I don't have the RadButton.  I've simplified my problem to the bare bones so here is the code:

    ASPX:
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnablePartialRendering="true">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManger1" runat="server"></telerik:RadAjaxManager>
    <telerik:RadWindow ID="RadWindow1" runat="server"></telerik:RadWindow>
    <script type="text/javascript">
        function OpenWindow() {
            var win = $find("<%=RadWindow1.ClientID%>").show();
        }
    </script>
    <div id="">
        <asp:Table ID="Table1" runat="server" />
    </div>
    </form>

    C#:
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        LoadTable();
    }
     
    private void LoadTable()
    {
        TableRow tr = new TableRow();
        Table1.Rows.Add(tr);
     
        TableCell tc = new TableCell();
        tr.Controls.Add(tc);
     
        LinkButton lb = new LinkButton();
        lb.Text = "Info";
        lb.OnClientClick = "OpenWindow()";
        tc.Controls.Add(lb);
    }

    The problem is that the RadWindow appears when the link is clicked but then promptly disappears again...  HELP !!!
  6. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 10 Jun 2014 Link to this post

    Hi Paul,

    You need to prevent the postback from the link button that dispsoses the RadWindow. Its popup is generated dynamically via JavaScript so it cannot survive postbacks.

    lb.OnClientClick = "OpenWindow(); return false;";

    I also strongly advise that you upgrade your controls version, because the 4 years old one you have does not support modern browsers and IE above 8.


    Regards,

    Marin Bratanov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. Paul
    Paul avatar
    4 posts
    Member since:
    Jun 2014

    Posted 10 Jun 2014 in reply to Marin Bratanov Link to this post

    Thanks Martin, I'll give it a go.

    Yeah I totally agree, I really need to upgrade - just need to find out who is going to pay for it!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017