先贴代码<asp:FileUpload ID="FileUpload1" runat="server" CssClass="text"  />
         &nbsp;<asp:Button ID="btn_FileUp" runat="server" Text="上传" 
        onclick="btn_FileUp_Click" />
    protected void btn_FileUp_Click(object sender, EventArgs e)
    {
        if (FileUpload1.PostedFile.ContentLength < 50 * 1024)
        {
            string ext = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
            if (ext != ".jpg" || ext != ".gif")
            {
                string tmp = FileUpload1.FileName;
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "a", "<script>alert('错误')</script>");
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(GetType(), "ab", "<script>alert('上传太大')</script>");
        }
    }
点击上传的时候。。有时候跳到无法显示 。路径没有变化。
然后我在点击事件的时候加了断点。发现在跳转到 无法显示的时候根本就没进入到 点击事件里面。。怎么才能给他弄稳定了啊?

解决方案 »

  1.   

    jquery.uploadify-v2.1.0 LZ何不用这个 很方便的
      

  2.   

    额,通常是超出大小限制了。asp.net的运行机制是先过,httphandler,httpmodule,而后才是自己的代码超出大小限制前面两个直接就给异常了是不会进你自己的代码里了所以治标的方法是在web.config里把文件大小设置的大点治本的方法是自己实现httphandler自己拦截post请求,自己判定
      

  3.   

      <httpRuntime maxRequestLength="49600" appRequestQueueLimit="60" executionTimeout="60"/>     其中maxRequestLength就是单个上传的文件大小了,这里是40M
      

  4.   

    <configuration>
    <system.web>
    <httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
    </system.web>
    </configuration>
    <configuration>
    <system.web>
    <processModel memoryLimit="80"/>
    </system.web>
    </configuration>