1

I'm using WebForms c#.

I have a few primary site links that I use everywhere - on menus, inline in text etc. I came up with the idea of trying to clean things up a bit as putting a hyperlink control in the middle of busy text is a pain to manage.

I came up with the idea of embedded codeblocks - they may be yesterdays technology, but they provide a simple way of getting simple bits of data into code.

I use routing and already have static methods to pull back routes. I also use enum to store route names.

All is good but in order to embed the method, I need to use the fully qualified name. I can circumvent that by adding a method to my basecontrol class, like this:

    protected string Link(RouteName name, string text)
    {
        return PageRoute.Link(name, text);
    }

Which gives me this:

<% =Link(MySite.BLL.Routing.RouteName.Privacy, "privacy policy") %>

However, I can't get rid of the fully qualified enum that sits in the same namespace as PageRoute.

Is there any way to achieve this, or perhaps another dierction I might take?

This is what I'd like to be able to do:

<% =Link(RouteName.Privacy, "privacy policy") %>
1
  • 2
    It seems like you have something working, but want to know whether it can be done differently. I think it may be worth asking this on codereview.stackexchange.com to get some feedback on your implementation. Commented Apr 13, 2015 at 9:57

1 Answer 1

1

You should be able to import the namespace in the aspx page.

<%@ Import namespace="MySite.BLL.Routing" %>
Sign up to request clarification or add additional context in comments.

1 Comment

Ah, thats what I was looking for Magnus.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.