HI All,
I am facing some issues while rad window closing process. Please find my requirement below....
i have one rad grid which is using to export excel file to DB. and i am using superate aspx page to open this as for window.now i want ot know how can i close widow after completing the uploading process.i want to know that my code is in C# Code behind.
here is my code:
distribute.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DistributeDialog.aspx.cs"
Inherits="DistributeDialog" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Distribute Activation Codes</title>
<link href="~/style/styles.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../style/Authentication.css" />
<link href="~/style/styles.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<style type="text/css">
html, body, form
{
padding: 0;
margin: 0;
height: 100%;
background: #f2f2de;
}
body
{
font: normal 11px Arial, Verdana, Sans-serif;
}
fieldset
{
height: 200px;
}
* + html fieldset
{
height: 168px;
width: 268px;
}
</style>
</head>
<body>
<form id="formDistributeDialog" method="post" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadFormDecorator ID="RadFormDecorator1" DecoratedControls="All" runat="server"
Skin="Sunset" />
<script type="text/javascript">
function GetRadWindow() {
var oWindow = null;
if (window.radWindow) oWindow = window.radWindow;
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
return oWindow;
}
//fix for Chrome/Safari due to absolute positioned popup not counted as part of the content page layout
function ChromeSafariFix(oWindow) {
var iframe = oWindow.get_contentFrame();
var body = iframe.contentWindow.document.body;
setTimeout(function() {
var height = body.scrollHeight;
var width = body.scrollWidth;
var iframeBounds = $telerik.getBounds(iframe);
var heightDelta = height - iframeBounds.height;
var widthDelta = width - iframeBounds.width;
if (heightDelta > 0) oWindow.set_height(oWindow.get_height() + heightDelta);
if (widthDelta > 0) oWindow.set_width(oWindow.get_width() + widthDelta);
oWindow.center();
}, 310);
}
</script>
<div style="width: 268px; height: 193px;">
<br />
<br />
<asp:Label ID="lblUpload" runat="server" Text="File upload:"></asp:Label>
<asp:FileUpload ID="FlUpload" runat="server" /><%--<asp:Image ID="imgDownloadInfo" runat="server"
ImageUrl="~/Images/Help.png" />--%>
<asp:Label runat="server" CssClass="lbl_errormsg_visible" Text="" ID="lblGenerationCodes"
Visible="false"></asp:Label>
<asp:RequiredFieldValidator ID="rfvUpload" Display="Dynamic" ControlToValidate="FlUpload"
ErrorMessage="Please select file!" Font-Names="Arial" Font-Size="11" runat="server"
ValidationGroup="update">
</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revFileUpLoadValidator" runat="server" ErrorMessage="Only (xls) allowed "
ValidationExpression="(.*\.xlsx)|(.*\.xls)" Display="Dynamic" ControlToValidate="FlUpload"
ValidationGroup="update">
</asp:RegularExpressionValidator>
<div style="margin: 20px 0 0 0;">
<div style="float: left; margin: 6px 0 0 18px;">
<asp:CheckBox ID="chkSendMail" runat="server" Text="Send emails to users" />
</div>
</div>
<div style="margin-top: 4px; text-align: right;">
<asp:Button ID="btnUpdate" runat="server" Text="Bulk Distribute" ValidationGroup="update"
OnClick="ExportExcelToSQL_onclik" />
<%--<input type="button" value="Cancel" onclick="" />--%>
</div>
<asp:TextBox ID="txtCompID" runat="server" Style="display: none;"></asp:TextBox>
</div>
</form>
</body>
</html>
Distribute.aspx.cs:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml;
using System.Net;
using System.IO;
using Microsoft.Office.Interop;
using Microsoft.Office.Interop.Excel;
using System.Reflection;
using System.Text;
public partial class DistributeDialog : System.Web.UI.Page
{
System.Data.DataTable dt = new System.Data.DataTable("dtExcel");
protected void Page_Load(object sender, EventArgs e)
{
string url = HttpContext.Current.Request.RawUrl;
if (CommonSession.CurrentUserId == null)
{
Response.Redirect("~\\Login\\Login.aspx");
}
else
{
if (url.IndexOf("?") == -1)
{
Response.Redirect("~\\Login\\login.aspx");
}
else
{
if (CommonSession.CurrentUserRole == "Superadmin")
{
txtCompID.Text = Request.QueryString["companyID"].ToString();
}
else
{
txtCompID.Text = CommonSession.CurrentUserCompanyId.ToString();
}
}
}
}
protected void ExportExcelToSQL_onclik(object sender, EventArgs e)
{
try
{
formDistributeDialog.Disabled = true;
lblGenerationCodes.Visible = false;
string SendmailToUsers;
File.Delete(Server.MapPath(@"~\Forms\TempFileUpload\") + FlUpload.FileName);
string Filename = Server.MapPath(@"~\Forms\TempFileUpload\") + FlUpload.FileName;
FlUpload.SaveAs(Filename);
string Ext = FlUpload.FileName.Substring(FlUpload.FileName.LastIndexOf(".") + 1);
string SheetName = FlUpload.FileName;
SheetName = SheetName.Replace(".xlsx", "");
SheetName = SheetName.Replace(".xls", "");
string ExceCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= " + Filename + "; Extended Properties=Excel 8.0";
System.Data.OleDb.OleDbConnection excelConnection = new System.Data.OleDb.OleDbConnection(ExceCon);
excelConnection.Open();
string OleStr = "SELECT * INTO [ODBC; " + ConfigurationManager.AppSettings["AONConnectionString"].ToString() + " ].[" + SheetName + "] FROM [" + SheetName + "$]\"";
System.Data.OleDb.OleDbCommand excelCommand = new System.Data.OleDb.OleDbCommand(OleStr, excelConnection);
excelCommand.ExecuteNonQuery();
excelConnection.Close();
WebClient webClient = new WebClient();
if (chkSendMail.Checked == true)
{
SendmailToUsers = "true";
}
else
{
SendmailToUsers = "false";
}
string overview = webClient.DownloadString(string.Concat(ConfigurationManager.AppSettings["AONServiceURL"].ToString(), "/UpdateActivationCodeInfoResult/", SheetName, "/", SendmailToUsers,"/", CommonSession.CurrentUserId.ToString(), "/", CommonSession.CurrentUserCompanyId.ToString()));
File.Delete(Server.MapPath(@"~\Forms\TempFileUpload\") + FlUpload.FileName);
if (chkSendMail.Checked == true)
{
lblGenerationCodes.Text = "File Uploaded Successfully & Mails Sent Successfully ";
lblGenerationCodes.Visible = true;
}
else
{
lblGenerationCodes.Text = "File Uploaded Successfully";
lblGenerationCodes.Visible = true;
}
GetRadWindowCloseScript();
}
catch (Exception ex)
{
lblGenerationCodes.Text = ex.Message;
lblGenerationCodes.Visible = true;
formDistributeDialog.Disabled = false;
}
}
public static string GetRadWindowCloseScript()
{
return @"
<script type='text/javascript'>
var oWindow = null;
if (window.radWindow)
oWindow = window.radWindow;
else if(window.frameElement.radWindow)
oWindow = window.frameElement.radWindow;
var currentWindow = oWindow;
currentWindow.Close();
</script>";
}
}
I am trying to accesing this as rad widow.fid that code in below;
<telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false"
ReloadOnShow="true" runat="server" Skin="Office2007" EnableShadow="true">
<Windows>
<telerik:RadWindow ID="DistributeWindow" Height="250px" Width="400px" Modal="true"
runat="server" Behaviors="Close" NavigateUrl="~/Forms/DistributeDialog.aspx"
OnClientClose="reBindCompanyOverviewPage">
</telerik:RadWindow>
</Windows>
</telerik:RadWindowManager>
now i want to close these windows after completion of My Export process.
PLease do me need full as soon as posible.
I am facing some issues while rad window closing process. Please find my requirement below....
i have one rad grid which is using to export excel file to DB. and i am using superate aspx page to open this as for window.now i want ot know how can i close widow after completing the uploading process.i want to know that my code is in C# Code behind.
here is my code:
distribute.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DistributeDialog.aspx.cs"
Inherits="DistributeDialog" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Distribute Activation Codes</title>
<link href="~/style/styles.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../style/Authentication.css" />
<link href="~/style/styles.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<style type="text/css">
html, body, form
{
padding: 0;
margin: 0;
height: 100%;
background: #f2f2de;
}
body
{
font: normal 11px Arial, Verdana, Sans-serif;
}
fieldset
{
height: 200px;
}
* + html fieldset
{
height: 168px;
width: 268px;
}
</style>
</head>
<body>
<form id="formDistributeDialog" method="post" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadFormDecorator ID="RadFormDecorator1" DecoratedControls="All" runat="server"
Skin="Sunset" />
<script type="text/javascript">
function GetRadWindow() {
var oWindow = null;
if (window.radWindow) oWindow = window.radWindow;
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
return oWindow;
}
//fix for Chrome/Safari due to absolute positioned popup not counted as part of the content page layout
function ChromeSafariFix(oWindow) {
var iframe = oWindow.get_contentFrame();
var body = iframe.contentWindow.document.body;
setTimeout(function() {
var height = body.scrollHeight;
var width = body.scrollWidth;
var iframeBounds = $telerik.getBounds(iframe);
var heightDelta = height - iframeBounds.height;
var widthDelta = width - iframeBounds.width;
if (heightDelta > 0) oWindow.set_height(oWindow.get_height() + heightDelta);
if (widthDelta > 0) oWindow.set_width(oWindow.get_width() + widthDelta);
oWindow.center();
}, 310);
}
</script>
<div style="width: 268px; height: 193px;">
<br />
<br />
<asp:Label ID="lblUpload" runat="server" Text="File upload:"></asp:Label>
<asp:FileUpload ID="FlUpload" runat="server" /><%--<asp:Image ID="imgDownloadInfo" runat="server"
ImageUrl="~/Images/Help.png" />--%>
<asp:Label runat="server" CssClass="lbl_errormsg_visible" Text="" ID="lblGenerationCodes"
Visible="false"></asp:Label>
<asp:RequiredFieldValidator ID="rfvUpload" Display="Dynamic" ControlToValidate="FlUpload"
ErrorMessage="Please select file!" Font-Names="Arial" Font-Size="11" runat="server"
ValidationGroup="update">
</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revFileUpLoadValidator" runat="server" ErrorMessage="Only (xls) allowed "
ValidationExpression="(.*\.xlsx)|(.*\.xls)" Display="Dynamic" ControlToValidate="FlUpload"
ValidationGroup="update">
</asp:RegularExpressionValidator>
<div style="margin: 20px 0 0 0;">
<div style="float: left; margin: 6px 0 0 18px;">
<asp:CheckBox ID="chkSendMail" runat="server" Text="Send emails to users" />
</div>
</div>
<div style="margin-top: 4px; text-align: right;">
<asp:Button ID="btnUpdate" runat="server" Text="Bulk Distribute" ValidationGroup="update"
OnClick="ExportExcelToSQL_onclik" />
<%--<input type="button" value="Cancel" onclick="" />--%>
</div>
<asp:TextBox ID="txtCompID" runat="server" Style="display: none;"></asp:TextBox>
</div>
</form>
</body>
</html>
Distribute.aspx.cs:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml;
using System.Net;
using System.IO;
using Microsoft.Office.Interop;
using Microsoft.Office.Interop.Excel;
using System.Reflection;
using System.Text;
public partial class DistributeDialog : System.Web.UI.Page
{
System.Data.DataTable dt = new System.Data.DataTable("dtExcel");
protected void Page_Load(object sender, EventArgs e)
{
string url = HttpContext.Current.Request.RawUrl;
if (CommonSession.CurrentUserId == null)
{
Response.Redirect("~\\Login\\Login.aspx");
}
else
{
if (url.IndexOf("?") == -1)
{
Response.Redirect("~\\Login\\login.aspx");
}
else
{
if (CommonSession.CurrentUserRole == "Superadmin")
{
txtCompID.Text = Request.QueryString["companyID"].ToString();
}
else
{
txtCompID.Text = CommonSession.CurrentUserCompanyId.ToString();
}
}
}
}
protected void ExportExcelToSQL_onclik(object sender, EventArgs e)
{
try
{
formDistributeDialog.Disabled = true;
lblGenerationCodes.Visible = false;
string SendmailToUsers;
File.Delete(Server.MapPath(@"~\Forms\TempFileUpload\") + FlUpload.FileName);
string Filename = Server.MapPath(@"~\Forms\TempFileUpload\") + FlUpload.FileName;
FlUpload.SaveAs(Filename);
string Ext = FlUpload.FileName.Substring(FlUpload.FileName.LastIndexOf(".") + 1);
string SheetName = FlUpload.FileName;
SheetName = SheetName.Replace(".xlsx", "");
SheetName = SheetName.Replace(".xls", "");
string ExceCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= " + Filename + "; Extended Properties=Excel 8.0";
System.Data.OleDb.OleDbConnection excelConnection = new System.Data.OleDb.OleDbConnection(ExceCon);
excelConnection.Open();
string OleStr = "SELECT * INTO [ODBC; " + ConfigurationManager.AppSettings["AONConnectionString"].ToString() + " ].[" + SheetName + "] FROM [" + SheetName + "$]\"";
System.Data.OleDb.OleDbCommand excelCommand = new System.Data.OleDb.OleDbCommand(OleStr, excelConnection);
excelCommand.ExecuteNonQuery();
excelConnection.Close();
WebClient webClient = new WebClient();
if (chkSendMail.Checked == true)
{
SendmailToUsers = "true";
}
else
{
SendmailToUsers = "false";
}
string overview = webClient.DownloadString(string.Concat(ConfigurationManager.AppSettings["AONServiceURL"].ToString(), "/UpdateActivationCodeInfoResult/", SheetName, "/", SendmailToUsers,"/", CommonSession.CurrentUserId.ToString(), "/", CommonSession.CurrentUserCompanyId.ToString()));
File.Delete(Server.MapPath(@"~\Forms\TempFileUpload\") + FlUpload.FileName);
if (chkSendMail.Checked == true)
{
lblGenerationCodes.Text = "File Uploaded Successfully & Mails Sent Successfully ";
lblGenerationCodes.Visible = true;
}
else
{
lblGenerationCodes.Text = "File Uploaded Successfully";
lblGenerationCodes.Visible = true;
}
GetRadWindowCloseScript();
}
catch (Exception ex)
{
lblGenerationCodes.Text = ex.Message;
lblGenerationCodes.Visible = true;
formDistributeDialog.Disabled = false;
}
}
public static string GetRadWindowCloseScript()
{
return @"
<script type='text/javascript'>
var oWindow = null;
if (window.radWindow)
oWindow = window.radWindow;
else if(window.frameElement.radWindow)
oWindow = window.frameElement.radWindow;
var currentWindow = oWindow;
currentWindow.Close();
</script>";
}
}
I am trying to accesing this as rad widow.fid that code in below;
<telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false"
ReloadOnShow="true" runat="server" Skin="Office2007" EnableShadow="true">
<Windows>
<telerik:RadWindow ID="DistributeWindow" Height="250px" Width="400px" Modal="true"
runat="server" Behaviors="Close" NavigateUrl="~/Forms/DistributeDialog.aspx"
OnClientClose="reBindCompanyOverviewPage">
</telerik:RadWindow>
</Windows>
</telerik:RadWindowManager>
now i want to close these windows after completion of My Export process.
PLease do me need full as soon as posible.