我的newtreepost.aspx:
<tr>
 <td align="center"><font color="#005ca1"><b>文件上传:</b></font></td>
 <td>
  <asp:label id="fileinfo" runat="server"></asp:label><br>
  <input id="upfile" type="file" size="63" name="upfile" runat="server">
  <asp:button id="upbutton" Runat="server" Height="23px" Text=" 上  传 "    CausesValidation="False"EnableViewState="False"></asp:button>
</td>
</tr>
newtreepost.aspx.cs:
private void upbutton_Click(object sender, System.EventArgs e)
{
if ((this.upfile.PostedFile.ContentLength == 0) ||(this.upfile.PostedFile.ContentLength > 0x4c4b40))
{
base.Response.Write("<script>window.alert('上传文件不能为空或不能大于5MB')</script>");
}
else
{
int num1 = this.upfile.PostedFile.FileName.LastIndexOf(@"\");
string text1 = this.upfile.PostedFile.FileName.Substring(num1 + 1);
string text2 = base.Server.MapPath(".") + @"\files\" + text1;
this.upfile.PostedFile.SaveAs(text2);
this.fileinfo.Text = this.fileinfo.Text + this.upfile.PostedFile.FileName + "<br>";
if ((this.upfile.PostedFile.ContentType == "image/gif") || (this.upfile.PostedFile.ContentType == "image/pjpeg"))
{
this.Notes.Text=this.Notes.Text + "<img src='http://localhost" + this.upfile.ResolveUrl("files/" + text1) + "'>";
}
else
{
this.Notes.Text=this.Notes.Text + "<a href='http://localhost" + this.upfile.ResolveUrl("files/" + text1) + "'>" + text1 + "</a>";
}
}
}
------------------------------------------------------------
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{    
this.Button2.Click += new System.EventHandler(this.Button2_Click_1);
this.Button1.Click += new System.EventHandler(this.Button1_Click_1);
this.upbutton.Click += new System.EventHandler(this.upbutton_Click);
this.Load += new System.EventHandler(this.Page_Load); }
设置了断点,但是点击 上传 按钮根本就没有什么反应?
大家说说这是怎么回事?

解决方案 »

  1.   

    LZ在Page_Load里面设置个断点
    顺便问一句,LZ在Page_Load里有加
    if (!IsPostBack)
    { }
    吗?
      

  2.   

    加了
    我在upbutton_click下加的断点,根本就不执行
    不知道是什么原因
    文件的权限也都设置了
      

  3.   

    一般来说只要走了后台就一定是先走Page_Load的,如果Page_Load里的代码都加在
    if (!IsPostBack)
    { }
    中了的话那就只能是button没有放在form中这种可能了
      

  4.   

    LZ 把这个事件删除,然后重新再添加一下,有时候VS2003是很不稳定的
      

  5.   

    其他的事件能执行吗?Page指令是否是这样的
    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebDemo.WebForm1" %>
      

  6.   

    对了
    LZ双击页面上的上传 按钮,看看是否跳到了设断点的这段代码上去
    -------------------------------
    没有什么反应,就是button_click下的代码没有反应
    其他的事件能执行吗?Page指令是否是这样的
    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebDemo.WebForm1" %>
    --------------------------------------------
    其他的事件都能执行,page指令也对,page_load也能执行
      

  7.   

    LZ还是没有明白我的意思
    在没有运行的情况下,双击VS2003画面编辑器上"上传"按钮,看看后台是生成了一个新的事件还是跳到了LZ写的上传按钮的事件上去了
      

  8.   

    to Ring850215(Ring):
    明白了你的意思了
    是的,双吉就转到那里了
      

  9.   

    谢谢大家乐,我用了上传组件,Webb.WAVE.Controls.Upload2,在web.config里面:
    <httpModules>
          <add name="UploadModule" type="Webb.WAVE.Controls.Upload2.UploadModule, Webb.WAVE.Controls.Upload2"/>
     </httpModules>
     <httpHandlers>
    <add verb="*" path="UploadStatusBar.ashx" type="Webb.WAVE.Controls.Upload2.UploadStatusHandler, Webb.WAVE.Controls.Upload2"/>
    </httpHandlers>
    我估计可能是这里的问题
    不好意思
      

  10.   

    问题是因为使用了Webb.WAVE.Controls.Upload2的原因