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

  • Home
  • SEARCH
  • 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 8501795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:18:25+00:00 2026-06-11T01:18:25+00:00

I have a function Static1Url in a .cs which does a job of pre-pending

  • 0

I have a function Static1Url in a .cs which does a job of pre-pending a URL string:

namespace Website2012
{
    public static class GlobalSiteFunctions
    {

        /// <summary>Returns a formatted URL mapping to Static1 on a CDN.</summary>
        /// <param name="url">The URL to be formatted.</param>
        /// <returns>Formatted string.</returns>
        public static string Static1Url(string url)
        {
            return string.Format("{0}{1}", ConfigurationManager.AppSettings["Static1CDNUrl"], url);
        }
    }
}

I’d like to be able to access this from an aspx page like so:

<p>This is the complete URL: <%= Static1Url("my-file-name.jpg") %></p>

At the moment, to be able to do this I must use the following code:

<p>This is the complete URL: <%= Website2012.GlobalSiteFunctions.Static1Url("my-file-name.jpg") %></p>

If I add an Import statement at the top of the page (<%@ Import Namespace="Website2012" %>) then I can now use the following:

<p>This is the complete URL: <%= GlobalSiteFunctions.Static1Url("my-file-name.jpg") %></p>

Call me lazy but I’d prefer an even simpler solution, preferably one that didn’t involve an Import at the top of the page but then didn’t mean I had to use a lengthy function call. Is this possible?

EDIT (For the benefit of Imran Balouch)

I have come up with this idea for handling multiple page types, is this good practice:

public class MyPage : System.Web.UI.Page
{
    public static bool Test()
    {
        return Functions.Test();
    }
}

public class MyUserControl : System.Web.UI.UserControl
{
    public static bool Test()
    {
        return Functions.Test();
    }
}


private class Functions
{
    public static bool Test()
    {
        return true;
    }
}
  • 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-11T01:18:27+00:00Added an answer on June 11, 2026 at 1:18 am

    The solution for this that can come in my mind is override the Page Class and in that overridden Page Class, write down your function and inherit every page of yours from the derived class, this way you can use it without using the import statement.

    public class MyPage : System.Web.UI.Page
    {
        protected string Static1Url(string url)
        {
            return string.Format("{0}{1}", ConfigurationManager.AppSettings["Static1CDNUrl"], url);
        }
    }
    

    than your page must be like:

    public partial class YourPage : MyPage
    {
    
    }
    

    and you can use it like:

    <p>This is the complete URL: <%= base.Static1Url("my-file-name.jpg") %></p>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have function which takes in an parameter of a class called Triple, and
I have function along these lines: public void view(string msg) { messagebox.show(msg); } .
I have function which append div (help icon) after all element with .help class.
i have function public Menu Details(int? id) { return _dataContext.Menu.Include(ChildMenu).FirstOrDefault(m => m.MenuId == id);
I have function some_func_1 which will create an object of type some_type and will
Inside my Controller i have function that runs after user clicks on item, which
i have function which return list as given below. List<User> lstUsers = SearchUsers(searchText); which
i have function, which has to accept two types of data - Observable collection
I have function CREATE OR REPLACE FUNCTION public.GetSoilCod ( cod1 integer = 0, cod2
I have function in Javascript which works fine using prototype. The function is used

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.