ASP.NET 4.0 Server Tags

We are migrating ASP.NET project from version 2.0 to 4.0

In previous version i had a specified below line of code:

<asp:CheckBox runat="server" ID="chkContentFilter" 
       Text="<%# SearchResultDictionary.ContentFilter %>" 
       OnCheckedChanged="chkFilterCheckbox_ValueChanged" AutoPostBack="True"
       EnableViewState="True" ></asp:CheckBox>

The problem is that in ASP.NET 4.0 <%# %> server tag doesn't maps data to control.

Of course there is a workaround to set control Text in code-behind. But i'm interesting is there a way to bind text on aspx layout?

Answers


You must call DataBind() on the container or control itself for <%# %> to be evaluated:

Data-Binding Expressions

Markup:

<asp:CheckBox runat="server" ID="chkContentFilter" 
       Text='<%# SearchResultDictionary.ContentFilter %>' 
       OnCheckedChanged="chkFilterCheckbox_ValueChanged" AutoPostBack="True"
       EnableViewState="True" ></asp:CheckBox>

Code-behind:

chkContentFilter.DataBind();

Need Your Help

How are you supposed to access EJB when using Easyrest?

java jboss resteasy

I have been trying to get Resteasy to work (and not it dose). However I now have another headache with accessing the EJB:s. I have tried injecting them, looking them up with jndi and most other sol...