我的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); }
设置了断点,但是点击 上传 按钮根本就没有什么反应?
大家说说这是怎么回事?
<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); }
设置了断点,但是点击 上传 按钮根本就没有什么反应?
大家说说这是怎么回事?
解决方案 »
- windows xp 安装程序提示
- 求助了 用SESSION提取登陆帐号出错
- gridview与bool字段
- vss checkout时没有获取最新版本 会不会自动得到其他人改动的最新信息
- 介绍同学进自己单位,高兴,散分!
- 大家看看,,,DataGrid的模版列,怎么清空DATAGRID的已经绑定的数据 要怎么做哦 立刻给分 我的信用,大家看着办
- 请做过的说说,关于对dataset的操作。。。。。
- 关于同一个解决方案下多个网站共用一套母版的问题
- 请教:如何在WebServer的登陆界面统计用户在线数?
- 关于在vs.net中编写asp.net代码时如何出现代码提示的问题?
- GridView CheckBox项为什么不显示,绑定一个字段又出错?
- 编写ascx自定义控件,运行却出错??
顺便问一句,LZ在Page_Load里有加
if (!IsPostBack)
{ }
吗?
我在upbutton_click下加的断点,根本就不执行
不知道是什么原因
文件的权限也都设置了
if (!IsPostBack)
{ }
中了的话那就只能是button没有放在form中这种可能了
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebDemo.WebForm1" %>
LZ双击页面上的上传 按钮,看看是否跳到了设断点的这段代码上去
-------------------------------
没有什么反应,就是button_click下的代码没有反应
其他的事件能执行吗?Page指令是否是这样的
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebDemo.WebForm1" %>
--------------------------------------------
其他的事件都能执行,page指令也对,page_load也能执行
在没有运行的情况下,双击VS2003画面编辑器上"上传"按钮,看看后台是生成了一个新的事件还是跳到了LZ写的上传按钮的事件上去了
明白了你的意思了
是的,双吉就转到那里了
<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>
我估计可能是这里的问题
不好意思