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

How to display a RadWindow from the code behind

2 Answers 193 Views
Window
This is a migrated thread and some comments may be shown as answers.
Herman Gouw
Top achievements
Rank 2
Herman Gouw asked on 29 Sep 2010, 08:03 AM
Hi,

I am using Telerik RadControls for ASP.NET AJAX Q2 2010 in my current project.

On one of the web pages there are 2 RadListBoxes (i.e. RadListBox1 and RadListBox2).

When the user transfers any items from RadListBox1 to RadListBox2, the web page will display a RadWindow containing a legal waiver statement with 2 buttons, OK and Cancel. If the user clicks on Cancel button, the transfer operation will be cancelled.

In order to do this, I need to display a RadWindows in RadListBox's event handler RadListBox_Transferring.

I could not find any samples on how to do this.

Can you please show me how to do the following:
1. display the RadWindow in the code behind RadListBox_Transferring
2. detect if the Cancel button is clicked on the RadWindow so that I can cancel the transfer operation (i.e. set e.Cancel to true).

The code is as follows:
ASPX:
<form id="form1" runat="server">
<div>
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
        <telerik:RadListBox ID="RadListBox1" AllowDelete="false" AllowReorder="false"
            AllowTransfer="true" AutoPostBackOnTransfer="true" TransferMode="Move"
            TransferToID="RadListBox2" OnTransferring="RadListBox_Transferring"
            runat="server" />
        <telerik:RadListBox ID="RadListBox2" AutoPostBackOnTransfer="true"
            OnTransferring="RadListBox_Transferring" runat="server" />
    </telerik:RadAjaxPanel>
</div>
<div>
    <telerik:RadWindowManager ID="RadWindowManager1" ReloadOnShow="true"
        ShowContentDuringLoad="false" runat="server" />
</div>
</form>

C#:
public partial class ListBoxes : Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.RadListBox1.Items.Add(new RadListBoxItem("Item1"));
            this.RadListBox1.Items.Add(new RadListBoxItem("Item2"));
        }
    }
  
    protected void RadListBox_Transferring(object sender, RadListBoxTransferringEventArgs e)
    {
        if (e.DestinationListBox.ID == "RadListBox2")
        {
            // Display RadWindow here
            // If user clicks the cancel button then do "e.Cancel = true;"
        }
    }
}

Regards,
Herman

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 29 Sep 2010, 10:10 AM
Hello Herman,


Here is the code that I tried to open the RadWindow from code.

Code:
protected void Button1_Click(object sender, EventArgs e) 
    RadWindow newWindow = new RadWindow(); 
    newWindow.NavigateUrl = "Redirect.aspx" 
    newWindow.VisibleOnPageLoad = true
    RadWindowManager1.Windows.Add(newWindow); 
}

You can also go through the following documentation for more information:
Setting Server-Side Properties

Thanks,
Princy.
0
Herman Gouw
Top achievements
Rank 2
answered on 04 Oct 2010, 02:06 PM
Thanks Princy.
Tags
Window
Asked by
Herman Gouw
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 1
Herman Gouw
Top achievements
Rank 2
Share this question
or