Reality Extractor
Reality Extractor

Reputation: 1277

how to add HTML to deployed app aspx page

Issue is SOLVED: Problem is that it is a pre-compiled web page project and to update the look/feel of the page it will need to be recompiled from source.

Deployed .Net application on IIS7.5, I only have access to the *.aspx files not the *.cs files or any other files that came with the project. The *.aspx pages start with the following (just one example):

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="blue.cs" Inherits="p9.cblue" %>

From everything I had read I should be able to just insert HTML markup, or insert JS, or follow the advice given in How to add html to an aspx C# codebehind page? @stackoverflow

I tried to remove the Inherits and the markup still wouldn't render in the browser.

I tried to insert the following JS right after the body tag in the aspx page:

<script type="text/javascript">document.write("TEST");</script>

It didn't show up.

I tried the suggestion given in the above link:

<script runat="server">
    protected void Page_Load(object sender, EventArgs e) {
        if (!Page.IsPostBack) {
            Controls.Add(new LiteralControl("TEST"));
        }
    }
</script>

<!-- Try this if the above does not work -->
<script runat="server">
        new protected void Page_Load(object sender, EventArgs e) {
        base.Page_Load(sender, e);
            if (!Page.IsPostBack) {
                Controls.Add(new LiteralControl("TEST"));
            }
        }
</script>

and neither of those methods worked either. I did restart the web server between attempts. I did even recycle the app pools between attempts. I did restart the browser to get away from caching issues. No joy.

I have to be missing something. It's inconceivable that it is so difficult to add some HTML to an aspx page. Seems like folks would need to do this quite frequently.

Once again, I don't have access to the *.cs files please don't respond with suggestions that require edits of the *.cs files. I also realize that I could use .Net Reflector to get the *.cs back out of the DLL and rebuild the solution from it. However, I shouldn't have to do any of this. I should be able to just add whatever markup I need to the *.aspx file and be done with it.

EDIT: One more piece of information which may or may not be relevant (I am not a dev so I am not sure on this). The directory where the app is located contains the *.aspx files. The directory on the file system where the images are located that are pulled into some of the pages the app renders does only contain a Default.aspx file which contains "This is a marker file generated by the precompilation tool, and should not be deleted!"

Upvotes: 0

Views: 1490

Answers (3)

Reality Extractor
Reality Extractor

Reputation: 1277

Like multiple folks have pointed out in comments, this was a precompiled web application and had thus be rebuild.

In the future, or for other folks looking at this page, this issue can be avoided by building the solution as a web page and ensuring that during the Publish Web Site step the "Allow this precompiled site to be updatable" checkbox is selected. This will allow you to change the markup and client-side code later without having to recompile the site.

Upvotes: 0

Dirk
Dirk

Reputation: 2388

My bets are on a caching issue. Your example code does not come through, but as long is you don't put the HTML code between ASP tags (because they are parsed by IIS before serving the resulting HTML), it should appear as you describe.

you can clear the IIS cache by running iisreset.exe from the commandline on the server

you can clear the browser cache locally, e.g. by using the Ctrl-F5 key combination

Upvotes: 1

Magnus Karlsson
Magnus Karlsson

Reputation: 3579

Add

    <script type="text/javascript">
        window.onload = function() {
            alert("Woot woot!");
        };
    </script>

to end of head tag in .aspx file and try again.

//Edit: What kind of project is it you have deployed? E.g. Web Setup Project or One-click publish?

Upvotes: 1

Related Questions