How to Open a RadWindow
In this article we will work see a demo of opening a RadWindow. We will open the window with the help of the javascript. We will also see how can we send a parameter to the popup window and use it in the window.
In .net we have a third party control called telerik controls. We can open a popup window using RadWindow control which comes under telerik controls list.Here i have discussed a demo for opening a popup window using RadWindow control.For this we have to take a Linkbutton on whose click RadWindow is opened.
Write below code inside the form tag:
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="return openWindow();">LinkButton</asp:LinkButton>
<telerik:RadWindow ID="RadWindow1" runat="server" Width="500" Height="390" Title="Add Employee"
VisibleStatusbar="False" DestroyOnClose="false" ShowContentDuringLoad="false" Behavior="Close, Move, Resize" Behaviors="Close, Move, Resize"
Modal="true" PreserveClientState="false"
ReloadOnShow="true">
</telerik:RadWindow>
</div>
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
</telerik:RadWindowManager>
<script type="text/javascript">
var oWnd;
function openWindow() {
debugger;
oWndadd = $find("<%= RadWindow1.ClientID %>");
oWndadd.setUrl("Employee.aspx");
oWndadd.SetTitle("Employee AddEdit");
oWndadd.Center();
oWndadd.show();
oWndadd.returnValue = false;
return false;
}
</script>We can pass a value from this javascript like below:
<asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="return openWindow(Id);">LinkButton</asp:LinkButton>
var oWnd;
function openWindow(Id) {
if (Id != 0) {
oWnd = $find("<%= RadWindow1.ClientID %>");
oWnd.setUrl("Employee.aspx?Id=" + Id);
oWnd.SetTitle("Employee AddEdit");
oWnd.Center();
oWnd.show();
oWnd.returnValue = false;
return false;
}
else {
oWndadd = $find("<%= RadWindow1.ClientID %>");
oWndadd.setUrl("Employee.aspx");
oWndadd.SetTitle("Employee AddEdit");
oWndadd.Center();
oWndadd.show();
oWndadd.returnValue = false;
return false;
}
}
and then in codebehind we can get value of Id as we get the value of querystring.
int id = Request.QueryString["Id"] != null ? Convert.ToInt32(Request.QueryString["id"].ToString()) : 0;