Developer Forum »
Reach a control inside ShoppingCartStatus
9 posts

Hi

I need to set the text of a literal inside EmptyCartTemplate from code behind. I've tried this, which doesn't work (the method GetLabel123() in the codebehind is never invoked):

<asp:Literal runat="server" ID="litLabel123" Text='<%# GetLabel123() %>'></asp:Literal>

I've also tried to find the literal through the ShoppingCartStatus-control:

Literal litBasketIsEmpty = (Literal)WAFShopHelper.FindControlRecursive(ShoppingCartStatus1, "litLabel123");

But it returns null (both from Page_Load and in the Init-callback).

So how can I reach this literal in order to set its Text property?

Guro

181 posts

Hi!

This example you provided:

<asp:Literal runat="server" ID="litLabel123" Text='<%# GetLabel123() %>'></asp:Literal>

Will not work, as you're calling a method with a data-binding expression. <%#. I think what you're looking for is:

<asp:Literal runat="server" ID="litLabel123" Text='<%= GetLabel123() %>'></asp:Literal>

 

Vidar

9 posts

Ok, thank you!

1