【发布时间】:2014-10-31 09:42:39
【问题描述】:
我在禁用 ASP.net 中的按钮时遇到了很大的问题。 当我禁用客户端的按钮时,回发后启用该按钮。 当我禁用服务器端的按钮时,我无法保存掩码,因为按钮不在。
我该如何解决这个问题? 保存动作在第一次 Preload/PostBack 上执行。 这意味着第二个 PostBack 和之后的所有内容都不应执行保存过程。
我的 Button 在每次预加载后都会创建新的。我怎样才能给这个按钮一个固定的 ID,以便它始终是我正在覆盖并且我可以访问的同一个对象。
在 .cs 中:
private void AddSaveButton()
{
ActionButton b = new ActionButton(GetString(6025));
b.ID = "ButtonSave";
b.ClientInstanceName = "ButtonSave";
b.UseSubmitBehavior = true;
b.Click += new EventHandler(save_event);
DivButton.Controls.Add(b);
}
在 aspx 中:
<div runat="server" id="DivButton" style="margin-top: 10px; padding-bottom: 15px; float: left">
动作按钮:
public class ActionButton : DevExpress.Web.ASPxEditors.ASPxButton
{
public ActionButton(string text)
{
this.Text = text;
this.CssClass = "actionButton";
this.CssPostfix = "actionButton";
this.AllowFocus = false;
this.UseSubmitBehavior = false;
this.CausesValidation = true;
}
}
【问题讨论】:
-
您在哪个阶段禁用了按钮?
-
参见my answer - 但坦率地说,我很困惑为什么您在
.cs文件而不是.aspx文件中创建按钮。
标签: c# javascript asp.net devexpress