代码如下:WebForm1.aspx  :<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="toobad.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script language="javascript" id="clientEventHandlersJS">
<!--function btn_onclick() {document.all("PhotoUpload").select();
document.selection.clear();}//-->
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<input class="TextBox_03" id="PhotoUpload" type="file" name="PhotoUpload" runat="server"><br>
<input type="button" id="btn" value="清空PHOTOUPLOAD的内容" language="javascript" onclick="return btn_onclick()">
<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 192px; POSITION: absolute; TOP: 112px" runat="server"
Text="提交"></asp:Button>
</form>
</body>
</HTML>*******************************************WebForm1.aspx.cs  :
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace toobad
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.HtmlControls.HtmlInputFile PhotoUpload;

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{    
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
Response.Write("<script>alert(\"提交了!!\")</script>");
}
}
}****************
为什么会这样,,你

解决方案 »

  1.   

    为什么会这样,,你先用PhotoUpload选择一个文件,,,里面有内容,然后点清空,,,,清空后,,点提交,,点第一次没反应,,,点第二次才行!!!!!!!为什么??????要如何让他点一次就行呢???????????????????????????/谢谢大家!!
      

  2.   

    听说这是违反W3c规则的,,,不过,,,还是要DINGGGGGGGGGGGGGG
      

  3.   

    <script language="javascript" id="clientEventHandlersJS">
    <!--function btn_onclick() {document.all("PhotoUpload").select();
    document.selection.clear();}//-->
    </script>加 return true;或<input type="button" id="btn" value="清空PHOTOUPLOAD的内容" language="javascript" onclick="btn_onclick()">试试
      

  4.   

    dingggggggggggggggggggggggg aaaaaaaaaaaaaaaaaaaaa