i have an HTML Button
as:
我有一个HTML按钮:
<asp:Button id="Button2" Text="Edit" class="but" runat="server"/>
<input id="Button2" type="button" value="Add" class="but" />
now, i want to set "display:none" to Add
button when Click on Edit
from code behind in
现在,我想在后面的代码中点击编辑时将“display:none”设置为Add按钮
asp.net. without applying runat="server"
to Add Button
.
asp.net。不将runat =“server”应用于添加按钮。
Help appreciated! Thanks
帮助赞赏!谢谢
1 个解决方案
#1
3
You will need to do several things in order to achieve this.
为了实现这一目标,您需要做几件事。
-
Create a property in your code behind that has the style you wish:
在您的代码后面创建一个具有您希望的样式的属性:
public string AddButtonStyle { get; set; }
-
Use this in your markup for the button:
在标记中使用此按钮:
<input id="Button2" type="button" value="Add" class="but" style="<%:AddButtonStyle %>" />
-
Set this style accordingly in the button click event:
在按钮单击事件中相应地设置此样式:
AddButtonStyle = "display: none;";
You may want to initialize the property to string.Empty
on page init.
您可能希望在init初始化属性为string.Empty。
#1
3
You will need to do several things in order to achieve this.
为了实现这一目标,您需要做几件事。
-
Create a property in your code behind that has the style you wish:
在您的代码后面创建一个具有您希望的样式的属性:
public string AddButtonStyle { get; set; }
-
Use this in your markup for the button:
在标记中使用此按钮:
<input id="Button2" type="button" value="Add" class="but" style="<%:AddButtonStyle %>" />
-
Set this style accordingly in the button click event:
在按钮单击事件中相应地设置此样式:
AddButtonStyle = "display: none;";
You may want to initialize the property to string.Empty
on page init.
您可能希望在init初始化属性为string.Empty。