I have a button in aspx page, I want to set its Enabled property using code behind variable.
I did it like this:
‘>
It gives me error message: Cannot create an object of type ‘System.Boolean’ from its string representation ‘<%=this.AllowDelete %>’ for the ‘Enabled’ property.
I changed it to Enabled = <%=this.AllowDelete %>,
It gives me error message: Server tags cannot contain <% … %> constructs.
I tested <%=this.AllowDelete %> in other place of page, it shows ‘false’ correctly.
How to set it for enabled property correctly?
It’s such a simple question but stuck me for a while. Any help is appreciated. Thanks you!
I know this doesn’t exactly answer your question, but are you able to set the button’s enabled property in Page_Load function in your code-behind?