Cal Cal - 1 year ago 82
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.

Answer Source

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...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download