Reputation: 3094
I have a check box on a page. I want to set it's enable property from a codebehind method.
I have done this Enabled= '<%#IsSMSEnabled()%>' />
IsSMSEnabled returns true or false depending on some logic.
Check box is alwyas enabled no matter what is returned by IsSMSEnabled()%
Upvotes: 1
Views: 808
Reputation: 58454
It depends on where you return the value from.
Try to set a property and assign its value inside code behind.
EDIT
I just heard that your checkbox is not inside a data control. So that would make more sense to directly change the checkbox.Checked value.
Upvotes: 0
Reputation: 52241
The <%# expressions
are evaluated at DataBind()
time and are not evaluated at all if DataBind()
is not called. You can call DataBind()
in PreRenderComplete
protected void Page_PreRenderComplete(object sender, EventArgs e)
{
DataBind();
}
Upvotes: 1
Reputation: 550
Instead of wrapping your method call in <%# %>
, try wrapping it in <%= %>
<%= sSMSEnabled() %>
Upvotes: 0