HiddenField not passing value to my <p></p> tag

107 Views Asked by At

Back-end:

protected void Page_Load(object sender, EventArgs e)
    {
            var data = File.ReadAllText(Server.MapPath("/Articles/12-19-2016/anotherworkingtitle.html"));
            HiddenFieldTest.Value = data.ToString();   
    }

Front-end:

    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="../../Scripts/jquery-3.1.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">

        $(document).ready(function () {
             var data = $("#<%=HiddenFieldTest.ClientID %>").val();
            $('#firstTest').html(data);
        });

          //Below is a test I tried

<%--        document.getElementById("#<%=HiddenFieldTest.ClientID %>").value = ('#firstTest');
        var data = document.getElementById("#<%=HiddenFieldTest.ClientID %>").value;
        $('#firstTest').html(data);--%>

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
   <div>
        <asp:Panel ID="aspTestArticle" runat="server">
        <asp:HiddenField ID="HiddenFieldTest" runat="server"/>
        <p id="firstTest" runat="server"></p>
        </asp:Panel>
    </div>
</asp:Content>

My Group Project is an entertainment news website that focuses on videogames and technology.

The code you see above the same code I've used for the prototype "Articles" page. It does work, but will not work on this new page.

What I do is when an Article is created and you press the Create button, a new folder with today's date is created. Inserted into that folder is the actual article file and a generated .aspx page(complete with .cs backend and designer.cs).

What's inserted is the code you see above.

The prototype page is working, but this page does not.

Code on this generated page and the prototype page are identical.

When accessing the page, everything is blank. When "Inspecting Element" with F12, I notice the HiddenField has a value="(article code)". It should not be doing that. It should be: (article code here)

Can I please get some assistance in finding a solution to this?

EDIT:: I thought it was my directory, so I changed my "src" on my script to reflect the additional folders. That didn't work.

EDIT2:: Here is the .html:

 <link href="../../CSS-StyleSheets/ArticleCSS.css" rel="stylesheet" />
<div class="header">
    <h1>another working title</h1>
    </div>
<body>
    <div class="body">
    <article>
        <h2>test</h2>
        <p class="article-meta"><strong>Author </strong>test,<strong> Published: </strong>12-19-2016</p>
        <h1>test</h1>
        <p>test</p>
    </div>
</body>
0

There are 0 best solutions below