Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8728863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:43:41+00:00 2026-06-13T08:43:41+00:00

I have a custom anchor create function public static Anchor Create(string name, object variant)

  • 0

I have a custom anchor create function

public static Anchor Create(string name, object variant)
{
    return new Anchor(string.Format("{0}{1}", (name.StartsWith("#") ? name : string.Format("#{0}", name)), variant).Replace(' ', '_'));
}

public static Anchor Create(string name)
{
    return Create(name, string.Empty);
}

Which creates the anchor tags on the webpage. The following is the call on the .ascx control

<asp:DataList ID="_meterLinkBar" runat="server" RepeatDirection="Horizontal" CssClass="bodytext4" RepeatLayout="Flow">
<ItemTemplate>
   <a href='<%# Anchor.Create("Meter", Container.ItemIndex + 1) %>' title='<%#  Eval("Name", "{0} measurement results") %>'>
  <%# FormatMeterName(Eval("Name") as string, Container.ItemIndex) %></a>
</ItemTemplate>

<SeparatorTemplate>|</SeparatorTemplate>
<FooterTemplate>
    <hr style="height: 1px; border-width: 0; color: #006690; background-color: #006690;" />
</FooterTemplate>
</asp:DataList>

The following is the actual item with the anchor tag

<ItemTemplate>
<a id='<%# Anchor.Create("Meter", Container.ItemIndex + 1) %>'></a>
....
</ItemTemplate>

EDIT

Here is the toString method

public override string ToString()
{
    return _name;
}

The following is the constructor

private Anchor(string name)
{
    _name = name;
}

Now everything works in IE, but in the other browsers, the links are rendered properly but the actual anchor tag itself shows as ##whatever

Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:43:42+00:00Added an answer on June 13, 2026 at 8:43 am

    Ideally, we probably need to see the HTML produced as well. It sounds like you are getting two # href="##name". If that is the case, then the Anchor’s .toString() method probably also adds the # before the name of the anchor. So, in that case, if it works in IE, it’s because IE ignores the repetition while other browsers do not ignore it.

    Check the .toString() method and see what’s in it. If it’s also adding the #, then you’d need to change your code like so:

    public static Anchor Create(string name, object variant)
    {
        return new Anchor(string.Format("{0}{1}", 
            (name.StartsWith("#") ? name.Replace('#','') : name),
            variant).Replace(' ', '_'));
    
    }
    

    EDIT

    Ah, I’m silly. I just realized, you are putting this in the “ID” of the <a> tag. You do NOT put # into the ID. You only put that into the href="#Meter", e.g.

    <a id='Meter' name='Meter'></a>
    
    <a href='#Meter'>Go back to Meter</a>
    

    If your id=’#Meter’, then that would cause problems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom html helper: public static MvcHtmlString MyLink(this HtmlHelper htmlHelper, string linkText,
I have custom validation rule: public function customRule($check) { } Inside this rule I
i have custom cell with 2 buttons(the function of these buttons is just to
I am working with jQuery 1.7.2. I have create a custom plug-in that loads
I have the need to put a custom attribute on an anchor which I
I have custom controller action for activating a new customer acount in a webshop.
I have a custom select menu (multiple) defined as follows: <select name=DanceStyles id=DanceStyles multiple=multiple
I have custom UITableViewCell . It contains UITextLabel . When I press this cell
I have custom classes that I currently instantiate within App.xaml as resources. I want
We have custom headers in the Silverlight DataGrid using the ContentTemplate. We've got a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.