Reputation: 19
I created loading window with telerik radwindow but I am not able close it from server side in C#.
Could anyone help me?
protected void bt_next_Click(object sender, EventArgs e)
{
string script = "function f(){ window.radopen(\"\", \"windows_loading\");Sys.Application.remove_load(f); }Sys.Application.add_load(f);";
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
//here i connect with database and insert all info to database and then i want close the radwindow.
}
Upvotes: 0
Views: 2395
Reputation: 1
this worked fro me:
aspx:
<asp:Button ID="Button1" runat="server" Text="Save" OnClick="Button1_Click" />
aspx script:
<script type="text/javascript">
function GetRadWindow() {
var oWindow = null;
if (window.radWindow)
oWindow = window.radWindow;
else if (window.frameElement && window.frameElement.radWindow)
oWindow = window.frameElement.radWindow;
return oWindow;
}
function CloseModal() {
GetRadWindow().close();
}
</script>
aspx.cs:
ClientScript.RegisterStartupScript(GetType(), "Javascript", "setTimeout(function(){ CloseModal(); },250);", true);
Upvotes: 0
Reputation: 3914
You can achieve the desired functionality like this, Server Side (i.e button click etc):
System.Web.UI.ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "CloseRadWindow();", true);
Then on Client Side use these Jquery Methods:
function CloseRadWindow() {
//get a reference to the current RadWindow
var wndow = GetRadWindow();
wndow .Close();
}
function GetRadWindow() {
var oWindow = null;
if (window.radWindow) oWindow = window.radWindow;
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
return oWindow;
}
Upvotes: 2