I'm still trying to copy a file from a network server to the web server and then view the file from the web server in another window. Using impersonation the file copy works fine in the server ItemCommand event. However the subsequent client side click event is not quite working.
I have a button called btnViewMapImage on my datalist control as follows:
<td><asp:TextBox ID="txtMapPage" runat="server" Text='<%# Eval("MapPage") %>' width="50" ReadOnly="true" />
<asp:Button ID="btnViewMapPage" runat="server"
CommandName = "ViewMapPage"
Path + Eval("MapPage") + "_" + Eval("StagedMapPageID") + ".tif") + ");" %>'/>
The code behind to process the button's server side click event is as follows:
protected void dlstGeneral_ItemCommand(ob
ject source, DataListCommandEventArgs e)
int intPropertyID = GetPropertyID();
// get the map page
//DataListItem item = e.Item;
//TextBox txt = (TextBox)item.FindControl(
TextBox txt = (TextBox)e.Item.FindContro
string strMapPage = txt.Text;
// get the server path where map pages are stored
string strPath = AppConfiguration.MapPagePa
// map pages always have a .tif extension
string strFrom = strPath + strMapPage + ".tif";
TextBox txtTo = (TextBox)e.Item.FindContro
string strTo = txtTo.Text;
// copy the file to the web server
string strStagedFile = StagedFileMgr.CopyIn(strFr
When I click the btnViewMapPage button the file gets copied correctly and the client side click event opens a new window with the following correct url
and the message "the page cannot be found".
However if I click IE's refresh button, the page displays as binary data which tells me the file is actually there now but wasn't there at the time of the client side click event..
If I click my view button again (which simply recopies the source file to the same target file name on the web server), the client side click successfully opens the file in a new window with the associated Microsoft Office Document Imaging application.
Why won't it work the first time around? Am I missing an event somewhere? Does the client side click event not fire after the server ItemCommand event? Do I need to invoke some sort of sleep function? How can I check in code that the file is totally there on the web server? I even added some code to use the Exists method of the FileInfo object after the file copy and loop until the result was true, and the onclientclieck event sill resulted in page cannot be found. What's going on here?