Question:
I have a disabled asp.Button, which I enable later with JavaScript. Like this
<asp:Button ID="btnSave" runat="server" Text="Save" Enabled="false" OnClientClick="; return ValidateFields();" OnClick="btnSave_Clicked" />
Answer:
However, the "onclick" method is not rendered as html when the control is disabled. My work around is to add the following code in PageLoad.
btnSave.Attributes["onclick"] = "return ValidateFields();";
探讨了在ASP.NET中如何处理禁用的asp.Button控件,并使用JavaScript使其在后期变为可用状态。通过在Page_Load事件中添加Attributes[onclick]属性,确保即使在控件初始为禁用状态下,onClick事件也能正确触发。
761

被折叠的 条评论
为什么被折叠?



