你可以将按钮类型由submit改为button
然后在button的onclick事件里自己写的函数里
进行提交或者其他操作

解决方案 »

  1.   

    首先谢谢各位的回答,是我没有把问题描述清楚,不好意思了。
        问题是这样的:   A是一个图片选择的页面(模态的),B则是一个图片上传的页面。A页面选择完图片后,点<提交>按钮,action触发B页面,由B来完成图片的上传工作。要求:1.当B完成图片上传以后,需要它自动关闭(这个没有问题)。2.要求在B页面关闭之后,再自动关闭A页面,并返回该图片文件名。因为图片上传需要一段时间,往往B页面还没有关闭,A页面就先关闭了。导致返回的文件名无法找到该图片而不显示(也正常,因为文件还没有传完,当然不存在了),这样产生了一个延时,需要传完后手动刷新才显示。想如何来判断B页面是否操作完成,再来关闭A页面,这样返回的图片文件就已经到服务器上了,也不会出现这个延时问题。
        顺便问题一下:图片文件名如果有中文,为什么不能显示?图片文件名的扩展名是大写的,也为什么不能显示?
      

  2.   

    ...之前俺好橡写了一个和楼主要求差不多的功能....
    主要就是 opener...如果页面间没有联系, 那基本上是不可能的.,,,中文名当然是编码问题...大写不能显示应该是服务器设置问题.
    1<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="utf-8" %>
    <%@ Assembly Name = "SQ" %>
    <%@ Assembly Name = "Sys" %>
    <%@ import Namespace="SQ" %>
    <%@ import Namespace="Sys" %>
    <%@ import Namespace="System.Data" %>
    <%@ import Namespace="System.Text.RegularExpressions" %>
    <script runat="server">
     string pageName = "";
     bool Debug = false;
     string bigid = System.Web.HttpContext.Current.Request.QueryString["bigid"]+"";
     string smallid = System.Web.HttpContext.Current.Request.QueryString["smallid"]+"";
     DataTable configDt = Datum.GetDataTable("select top 1 * from productconfig", Sys.Conn, "config");
     
     void Page_Init(Object s, EventArgs e)
     {
      if(!Sys.HasLoginBool())
      { 
       Utility.GoBackByResp
        ("您尚未登陆本系统, 请先登陆, 3 秒后转到登陆页, 还有 ", 3, "/mod/system/login/");
       Response.End();
      }
     } // end void Page_Init
     
     void Page_Load(Object s, EventArgs e)
     {
      
      if(Debug)
      {
       Response.Write("<li/>bigid: "+bigid);
       Response.Write("<li/>smallid: "+smallid);
      }
      
      Upload up = new Upload();
       
       up.Debug = false;
       up.AutoRename = true;
       
       up.UploadPath = configDt.Rows[0]["prdUpPath"]+"";
       up.Extension = ".bmp|.gif|.jpg|.jpeg|.png|.swf";
       
       up.GoBackUrl = Request.ServerVariables["HTTP_REFERER"]+"";
       
       up.UploadSessionName = "sqUploadCheckInterver";
       
       up.Interval = 10;
       up.GoBackSecond = 10;
       
       up.TotalItem = 1;
       
       up.TotalKb = 1024*5;
       up.SingleKb = 1024*5;
       
       up.UploadPlaceHolder = ph;
       up.ReturnFilePath=new OneArgStringDelegate(GetPath);
       up.Go();
       
       up = null;
     } // end Page_Load
     
     public void GetPath(String sPath)
     {
      bool Debug = true;
      
      if(Debug)
      {
       System.Web.HttpContext.Current.Response.Write("<li/>sPath: "+sPath);
      }
      
      string bigpath = sPath;
      string smallpath = configDt.Rows[0]["prdUpThumbPath"]+""+System.IO.Path.GetFileName(sPath);
      
      Thumb.file
      (
       sPath, 
       smallpath, 
       int.Parse(configDt.Rows[0]["prdThumbW"]+""),
       int.Parse(configDt.Rows[0]["prdThumbH"]+""),
       true
      );
      
      String scriptString = "<script>";
      scriptString +="var bigimg = opener.document.getElementById('"+bigid+"');";
      scriptString +="bigimg.value='"+bigpath+"';";
      scriptString +="var bigimg = opener.document.getElementById('"+smallid+"');";
      scriptString +="bigimg.value='"+smallpath+"';";
      scriptString +="alert('上传完毕');self.close();";
      scriptString += "<";
      scriptString += "/";
      scriptString += "script>";
      
      Page.RegisterStartupScript("Startup", scriptString);
     }
    </script>
    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><% Response.Write(Sys.auSubjectZh); %></title>
    <script type="text/javascript">
    /*<![CDATGA[*/
     onload = function()
     {
      var Debug = false;
      
      if(Debug)
      {
       if(opener!=null)
       {
        var bigimg = opener.document.getElementById("<%Response.Write(bigid);%>");
        bigimg.value="ok, test this";
        
        var smallid = opener.document.getElementById("<%Response.Write(smallid);%>");
        smallid.value="ok, test this";
       } // end if 1
      } // end if
     } // end onload
    /*]]>*/
    </script>
    </head>
    <body>
    <form id="Form1" method="post" runat="server">
     <asp:PlaceHolder id=ph runat=server 
     />
    </form></body>
    </html>