简体   繁体   中英

How can I hide this button in ASP.NET getting value from Method?

I have a button in HTML like this:

<button id="EditTemplate" value="<%=this.GetUrlEncode() %>" class="btn-primary" type="button">
<em class="fa fa-edit"></em>Edit template

Because I'm using the Value="<%=this.GetUrlEncode() %>" , It can't have runat="server" as property because the button will not work. The problem is that I need to hide and show the button in c#:

this.EditTemplate.Visible = false/true;

It doesn't work because it needs to be runat="server" . Any ideas?

I just found the solution by adding an attribute called value in the C# code like this

EditTemplate.Attributes.Add("value", this.GetUrlEncode());

so this let me to set runat="server" and still works

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM