点两次页面肯定要提交两次,有可能就是效率的问题,如果用visible = false 或 wideth = 0好象这个按钮实际上仍然存在,如果我用Enable = false,那应该解决这个问题,各位觉得怎样
在数据库去判断是实在没办法的时候才用那一招

解决方案 »

  1.   

    用alter不利于快速操作,因为需要快速录入,用户敲一下回车键(或点一次鼠标)就要保存,同时就需要输入下一条数据,弹出一个提示框显然影响速度
      

  2.   

    学习CSDN的“发出回复”,让他一次后无效
      

  3.   

    应该是enable = false,我点了一下
    呵呵
      

  4.   

    我的程序也有这个问题,当用户提交后,后台需要执行时间比较长的时候,如果点击两次,程序会执行两次。
    初步想法是写一个自定义的服务器控件按钮,自己定义服务器端点击事件,在
    主要代码为:
    writer.AddAttribute("OnClick","JavaScript:" + Page.GetPostBackEventReference(this)+";this.disabled='disabled'");
    这样利用_doPostBack()来提交页面,提交后按钮变灰不能用。当页面刷新后,按钮自动恢复成可用状态.
    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.ComponentModel;namespace test
    {

    /// <summary>
    /// WebCustomControl1 的摘要说明。
    /// </summary>
    [DefaultProperty("Text"), 
    ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")]
    public class WebCustomControl1 : System.Web.UI.WebControls.WebControl,System.Web.UI.IPostBackEventHandler
    {
    private string text;
    public event System.EventHandler OnClick2;
    [Bindable(true), 
    Category("Appearance"), 
    DefaultValue("")] 
    public string Text 
    {
    get
    {
    return text;
    } set
    {
    text = value;
    }
    } /// <summary> 
    /// 将此控件呈现给指定的输出参数。
    /// </summary>
    /// <param name="output"> 要写出到的 HTML 编写器 </param>
    protected override void Render(HtmlTextWriter output)
    {
    output.AddAttribute("type","button");
    output.AddAttribute("name",this.UniqueID);
    output.AddAttribute("value",this.text);
    output.AddAttribute("onclick","javascript:"+Page.GetPostBackEventReference(this)+";this.disabled='disabled'");
    output.RenderBeginTag("input");
    output.RenderEndTag();

    }
    #region IPostBackEventHandler 成员 public void RaisePostBackEvent(string eventArgument)
    {
    // TODO:  添加 WebCustomControl1.RaisePostBackEvent 实现
    if(this.OnClick2!=null)
    {
    this.OnClick2(this,System.EventArgs.Empty);
    }
    } #endregion
    }
    }