Reputation: 18485
I would like to generate my links automatically via a static class in each of my aspx pages (or in a common BasePage).
Currently I use this:
private const string TEMPLATE =
"~/One.aspx";
public static string Link ()
(
string link = String.Format(TEMPLATE);
return link;
)
But the name of my page, One.aspx is hardcoded. Is it possible to generate the path instead of this hardcoded constant TEMPLATE. You should know that I do not instantiate the class before creating the link.
The idea is to never hardcode a link but use a variable in my Redirect()
HttpContext.Current.Response.Redirect(PageOne.Link);
Upvotes: 1
Views: 103
Reputation: 30873
You can use a T4 script which generates the desired class according to project structure and filenames.
Upvotes: 2