views:

24

answers:

4

i have this on my master.page

<ul class="menu">
    <li class="first" runat="server" id="Li2">
        <a runat="server" id="A1" href="../NewEntry.aspx">Create a New Entry</a>
    </li>
</ul>

when i go to content page ("NewEntry.aspx") i want the link name to be changed to "Update Entry"

<ul class="menu">
     <li class="first" runat="server" id="Li2">
         <a runat="server" id="A1" href="../UpdateEntry.aspx">Update Entry</a>
     </li>
</ul>

any feedback?

A: 

You can use a hyperlink control <asp:hyperlink> and set the url as well as the text values.

mjw06d
+1  A: 

Make the link an asp:Hyperlink. Then have the master page expose a function or property:

public void SetLink(string href, string text)
{
    A1.NavigateURL = href;
    A1.Text = text;
}

Call the function from the main page.

egrunin
A: 

I would recommend handling this as a HyperLink control as others have mentioned. If for some reason you must handle this as a server-side HTML anchor, you can access it using the following code from your webform code-behind:

HtmlAnchor link = (HtmlAnchor)(this.Master).FindControl("A1");
link.InnerText = "Update Entry";
Nathan Donze
A: 

You can also define a content place holder where you have "Create a New Entry". Leave that as the default inside that place holder, and only in the content page set content for it to Update Entry.

eglasius