c# 点击保存之后禁用Input(Button)按钮 求教育

cc576161825 2012-01-04 02:01:03
我试了试,但是不成功!,帮我看看哪错了

js禁用按钮
function clossbutton()
{
document.getElementById("BtnAdd").disabled=true;
}
后台代码调用.cs

Page.ClientScript.RegisterStartupScript(this.GetType(), "", "clossbutton()", true);

前台按钮

<input id="BtnAdd" type="button" onclick="getSelect();" />
...全文
663 14 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
cc576161825 2012-01-05
  • 打赏
  • 举报
回复
我的问题解决了,谢谢大家了散分
cc576161825 2012-01-05
  • 打赏
  • 举报
回复
楼上谢谢了,写的很好,什么都考虑进去了,但我看不懂
槑党--一缕风 2012-01-05
  • 打赏
  • 举报
回复
防止重复提交按钮的控件 希望对你有所帮助

/// <summary>
/// 表示一个防止重复提交的按钮。当用户单击按钮以后,该按钮变灰,不能再次单击,直到重新加载页面或者跳转。
/// </summary>
[DefaultProperty("Text")]
[ToolboxData("<{0}:ButtonOnce runat=server></{0}:ButtonOnce>")]
public class ButtonOnce : System.Web.UI.WebControls.Button
{
/// <summary>
/// 默认的构造函数。
/// </summary>
public ButtonOnce()
{
this.ViewState["afterSubmitText"] = "正在提交,请稍候...";
base.Text = "按钮1";
this.ViewState["showMessageBox"] = false;
this.ViewState["showAfterSubmitText"] = false;
this.ViewState["warningText"] = "确定要提交吗?";
}

/// <summary>
/// 获取或设置单击按钮后,按钮上所显示的文本。
/// </summary>
[Bindable(true),
Category("Appearance"),
DefaultValue(false),
Description("点击按钮后,是否显示提交状态")]
public bool ShowAfterSubmitText
{
get
{
return (bool)this.ViewState["showAfterSubmitText"];
}
set
{
this.ViewState["showAfterSubmitText"] = value;
}
}

/// <summary>
/// 获取或设置单击按钮后,按钮上所显示的文本。
/// </summary>
[Bindable(true),
Category("Appearance"),
DefaultValue("正在提交,请稍候..."),
Description("指示单击提交后,按钮上所显示的文本。")]
public string AfterSubmitText
{
get
{
string afterSubmitText = (string)this.ViewState["afterSubmitText"];
if (afterSubmitText != null)
{
return afterSubmitText;
}
else
{
return string.Empty;
}
}
set
{
this.ViewState["afterSubmitText"] = value;
}
}

[Bindable(true),
Category("Appearance"),
DefaultValue(false),
Description("指示是否要显示一个提示框。")]
public bool ShowMessageBox
{
get
{
return (bool)this.ViewState["showMessageBox"];
}
set
{
this.ViewState["showMessageBox"] = value;
}
}

[Bindable(true),
Category("Appearance"),
DefaultValue("确定要提交吗?"),
Description("指示提示框内所包含的内容。")]
public string WarningText
{
get
{
return (string)this.ViewState["warningText"];
}
set
{
this.ViewState["warningText"] = value;
}
}

/// <summary>
/// AddAttributesToRender
/// </summary>
/// <param name="writer">HtmlTextWriter</param>
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
System.Text.StringBuilder ClientSideEventReference = new System.Text.StringBuilder();

if (((this.Page != null) && this.CausesValidation) && (this.Page.Validators.Count > 0))
{
ClientSideEventReference.Append("if (typeof(Page_ClientValidate) == 'function'){if (Page_ClientValidate() == false){return false;}}");
}
//ShowMessageBox?
if (this.ShowMessageBox)
{
ClientSideEventReference.Append("if (!confirm('" + this.WarningText + "')){return false}");
}
if (ShowAfterSubmitText)
{
ClientSideEventReference.AppendFormat("this.value = '{0}';", (string)AfterSubmitText);
}
ClientSideEventReference.Append("this.disabled = true;");
ClientSideEventReference.Append(this.Page.ClientScript.GetPostBackEventReference(this, string.Empty));

writer.AddAttribute(HtmlTextWriterAttribute.Onclick, ClientSideEventReference.ToString(), true);
base.AddAttributesToRender(writer);
}
}
cc576161825 2012-01-05
  • 打赏
  • 举报
回复
(【孟子E章】)
<input id="BtnAdd" type="button" onclick="getSelect();this.disabled='disabled'" />


这个方法效果只能是当时点击时不可用,有没有办法一直不可用
cc576161825 2012-01-05
  • 打赏
  • 举报
回复
[Quote=引用楼主 cc576161825 的回复:]
▪ IaaS、PaaS和SaaS的主要关系是...▪ 公有云和私有云有哪些不同?▪ 云计算的公共特征有?▪ 物联网与云计算是什么关系?▪ 相对于公共PaaS,私人PaaS有哪...
我试了试,但是不成功!,帮我看看哪错了

js禁用按钮
function clossbutton()
{
document.getElementById("BtnAdd").disabled=tr……
[/Quote]


这个方法效果只能是当时点击时不可用,有没有办法一直不可能
阿非 2012-01-04
  • 打赏
  • 举报
回复
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "clossbutton()", true);

写在那里了?
阿非 2012-01-04
  • 打赏
  • 举报
回复
你怎么操作的,不成功?
cf_nxcxy 2012-01-04
  • 打赏
  • 举报
回复
document.getElementById("BtnAdd").disabled=0;
Ny-6000 2012-01-04
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 jason_dct 的回复:]
引用 1 楼 net_lover 的回复:
<input id="BtnAdd" type="button" onclick="getSelect();this.disabled='disabled'" />


+1
[/Quote]

+1
熙风 2012-01-04
  • 打赏
  • 举报
回复
段传涛 2012-01-04
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 net_lover 的回复:]
<input id="BtnAdd" type="button" onclick="getSelect();this.disabled='disabled'" />
[/Quote]

+1
孟子E章 2012-01-04
  • 打赏
  • 举报
回复
你的
后台代码调用.cs,需要提交到服务器端才能执行,所以,客户端不能立即看到的
所以你需要在客户端执行调用
段传涛 2012-01-04
  • 打赏
  • 举报
回复
disabled 不可用
孟子E章 2012-01-04
  • 打赏
  • 举报
回复
<input id="BtnAdd" type="button" onclick="getSelect();this.disabled='disabled'" />

111,098

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧