asp.net expression builder within a larger string

325 Views Asked by At

Is there a way to embed an expression builder within a larger string?

I'm trying to create a hyperlink where the URL includes an embedded expression. I tried writing

<asp:hyperlink id="add" runat="server" text="Add" NavigateUrl="~/admin/customer.aspx?code=<%$ AppSettings:salecode %>&action=add" />

But this didn't work -- the "<%$" and all just got included as text, no substitution was done.

Of course I could build the URL in code, it's no big deal, but I just wonder if it's possible to do this in the ASPX file somehow.

PS Just as a test, I tried putting

<asp:label id="test" runat="server" text="<%$ AppSettings:salecode %>" />

and that worked fine, so it's not that I'm mis-spelling the setting name or something dumb like that.

1

There are 1 best solutions below

1
On

Try using single quotes around the NavigateUrl property:

NavigateUrl='~/admin/customer.aspx?code=<%$ AppSettings:salecode %>&action=add'