I have a TabPanel whose HeaderText property I want to set using a code behind function
eg.
<asp:TabPanel ID="id" runat="server" HeaderText='<%= String.Format("{0}","some text") %>'>
I can’t put the function call between the start and end tags because it is a TabPanel, but when I do the above I just get an empty header on the page. I have also tried <%# %> (I am not sure of the difference between the two).
The String.Format is just an example, not the real function I am trying to call.
I know some attributes don’t support inline syntax, and this might be one of them, unfortunately. The syntax looks okay, which makes me think that might be the case. To workaround this issue, just set the
HeaderTextin code-behind.As for the difference between
<%= ... %>and<%# ... %>, the latter is used strictly for databinding syntax:EDIT
There’s actually an easier way that I didn’t think of before. Just use the
HeaderTemplateto set the column header text dynamically: