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

RadWindow as an info box that stays open

5 Answers 65 Views
Window
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 09 Jun 2014, 06:19 PM
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?

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 Jun 2014, 06:15 AM
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.
0
Paul
Top achievements
Rank 1
answered on 10 Jun 2014, 06:56 AM
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);
0
Paul
Top achievements
Rank 1
answered on 10 Jun 2014, 08:42 AM
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 !!!
0
Marin Bratanov
Telerik team
answered on 10 Jun 2014, 10:17 AM

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.

 
0
Paul
Top achievements
Rank 1
answered on 10 Jun 2014, 10:36 AM
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!
Tags
Window
Asked by
Paul
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Paul
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or