Cal Cal - 3 months ago 27
ASP.NET (C#) Question Webforms add static content to all screens

We have a Webforms application, in which no master page was used. There are about 50-60 screens.

Now we have the requirement to add static content to each of the screens as a footer. Is there a way to achieve it programmatically, without modifying each of the screens?

Thank you for your time.


The easiest way I can think of is to create a Class in the assembly of the project and use that on every page. You still need to edit all pages once to add one line of code, but after that you can maintain it in a single location for the entire project.

In a class file somewhere in the project.

public static string pageFooter()
    StringBuilder sb = new StringBuilder();

    sb.Append("This is the footer.");

    return sb.ToString();

And then put this on every aspx page.

<%= WebApplication1.pageFooter() %>

Better still would be to start using a Master page...