I want to call MyMethod in the server control code on an aspx page, as shown below.
Mypage.aspx
<asp:Label ID="MyLabel" runat="server" Text='<%# MyMethod(Eval("MyColumn")) %>'>
MyPage.aspx.cs
protected void MyMethod(object obj) { ... }
If I use "
instead of '
in an aspx page, this will give me a compilation error. The server tag is not formed .
<asp:Label ID="MyLabel" runat="server" Text='<%# MyMethod(Eval("MyColumn")) %>'> // This line work <asp:Label ID="MyLabel" runat="server" Text="<%# MyMethod(Eval("MyColumn")) %>"> // This line error
I want to know why I need to use a single quote, is this a rule? How to use double quote in my situation?
source share