tags:

views:

62

answers:

2

I've tried both snippets below. Nothing. I've tried <%#, <%=, and <%. Nothing. So I'm stuck.

<div style="background-color:Gray; color:white; text-align:center; width:100%;">
            <asp:HyperLink ID="HyperLink1" Target="_blank"  NavigateUrl='<%= Server.HtmlEncode(String.Format("~/ShowHistory.aspx?section={0}&jobnumber={1}", "APQP Header", "101244")) %>' runat="server">Show Updated History</asp:HyperLink>&nbsp;&nbsp;
            <asp:HyperLink Target="_blank" NavigateUrl="~/ShowDeletedHistory.aspx" ID="HyperLink2" runat="server">Show Deleted History</asp:HyperLink></div>
        <br />

<div style="background-color:Gray; color:white; text-align:center; width:100%;">
            <asp:HyperLink ID="HyperLink1" Target="_blank"  NavigateUrl='<%= String.Format("~/ShowHistory.aspx?section={0}&jobnumber={1}", "APQP Header", "101244") %>' runat="server">Show Updated History</asp:HyperLink>&nbsp;&nbsp;
            <asp:HyperLink Target="_blank" NavigateUrl="~/ShowDeletedHistory.aspx" ID="HyperLink2" runat="server">Show Deleted History</asp:HyperLink></div>
        <br />
+2  A: 

Try <%# ... %> and call this.DataBind() (or Me.DataBind()) when your page loads.

Heinzi
This worked. But it broke the textChanged Event I was using. So I used the solution below.
dotnetN00b
A: 

Server controls cannot contain this type of tags. The reason is that "<%= %>" is basically equal to Response.Write, which itself executes after the page has gone through its lifecycle, when the response is already constructed. If you use it when setting a value of a server-side control property, this value has to be resolved when (or a little after) parsing the page markup. This is the reason you cannot use "<%= %>" in a server control.

If it was a normal html tag, it would work, but the virtual URL would not.

Is there a reason you're not setting the NavigationUrl in code? It would look much nicer to me.

Slavo
Putting the URL in code-behind worked. Although, I had to put in LoadComplete event instead of the Load event. I have the Control Toolkit in my page. And somehow when I had the Navigation URL in Page_Load, the event did not fire and the URL didn't load. But when I put them in Page_LoadComplete, it worked just fine.
dotnetN00b