By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,728 Members | 1,154 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,728 IT Pros & Developers. It's quick & easy.

Export Excel Question

P: n/a
Hi all,

I have a parent page(parent.aspx) which will open different new windows
depending on the user input.

for example,
the new windows are opened using the following code :
window.open('child.aspx', document.userinput.value)

In the child.aspx, the result is rendered as Excel, Word, PDF, etc...
depending on the input parameters from the parent pages.

There is no problem when the user just open 1 pop up window.
However, when the user first open a Excel Window, and then open another
window (Word) , the first window will become blank. Then the result in the
second window
will become the result in first window (Excel).

Thank You.
Sep 20 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Here are the sample codes.
Parent.html :

<html>
<head>
<script language=javascript>
function OpenWindow()
{
var oWnd = window.open('', document.frmOption.selOption.value);
document.frmOption.target = document.frmOption.selOption.value;
document.frmOption.submit();

}
</script>
</head>
<body>
<form id=frmOption name=frmOption method=post action="child.aspx">
<select id=selOption name=selOption>
<option value=1>Excel</option>
<option value=2>Word</option>
</select>
<input type=button value="Open Window" onclick="OpenWindow()">
</form>
</body>
</html>

Put the following code in Child.aspx :
c#

if (Request["selOption"].ToString().Trim() == "1")
{
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition",
"inline;filename=excel.xls");
Response.Write("This is Excel");
}
else
{
Response.ContentType = "application/vnd.msword";
Response.AddHeader("Content-Disposition",
"inline;filename=word.doc");
Response.Write("This is Word");
}
Response.End();
vb.net

if Request("selOption").ToString().Trim() = "1" Then
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("Content-Disposition",
"inline;filename=excel.xls")
Response.Write("This is Excel")
else
Response.ContentType = "application/vnd.msword"
Response.AddHeader("Content-Disposition",
"inline;filename=word.doc")
Response.Write("This is Word")
end if
Response.End()

Sep 20 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.