locked
how to load an html pages in aspx or aspx.cs files RRS feed

  • Question

  • User-605499000 posted

    I am trying to open html pages in the default aspx files and It is not working.  The aspx.cs file opens the javascript and css files.

    In order to change to responsive pages I have to change the fixed text that I had in javacript to liquid text.  Below are the default files that we used in the original program.

    They use to open up the javascript files for a magazine of at least 20 pages. Hope you can guide me.  Jen

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Bumples.UI.Issues_Default" %>

    <!doctype html >
    <html>

    <head>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <title>Bumples Magazine</title>


    <link rel="stylesheet" href="../Css/MagazineStyles.css" type="text/css" />

    <script src="/Issues/JavaScript/Movime.js"></script>
    <script src="/Issues/JavaScript/DivClass.js"></script>
    <script src="/Issues/JavaScript/TalkingBalloon.js"></script>
    <script src="/Issues/JavaScript/Magazine.js"></script>
    <script src="/Issues/JavaScript/PuzzleClass.js"></script>
    <script src="/Issues/JavaScript/MemoryClass.js"></script>
    <script src="/Issues/JavaScript/MoveObjectTo.js"></script>

    <%= LoadCss() %>
    </head>

    <body onLoad="BmOnLoad();">
    <form id="form1" runat="server">
    <div>  (Note can I put the issue in here to open the pages of the html files. If so how.)

    </div>
    </form>

    <script type="text/javascript">
    try {
    var pageTracker = _gat._getTracker("UA-10539155-1");
    pageTracker._trackPageview();
    } catch (err) { }
    </script>

    </body>
    </html>

    using System;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;

    using System.IO;
    using System.Security;

    using Bumples;

    namespace Bumples.UI
    {
    public partial class Issues_Default : BasePage
    {
    private Int32 issue = 0;
    private String section = "";

    protected void Page_Load(object sender, EventArgs e)
    {
    //
    if (String.IsNullOrEmpty(this.Request.QueryString["Issue"]))
    {
    this.issue = 1;
    //throw new SecurityException("Error loading Issue!");
    }
    else
    {
    try
    {
    this.issue = Int32.Parse(this.Request.QueryString["Issue"]);
    }
    catch
    {
    this.issue = 1;
    }
    }

    if (issue < 1 || issue > 25)
    {
    issue = 1;
    //throw new SecurityException("Error loading Issue!");
    }

    //
    if (String.IsNullOrEmpty(this.Request.QueryString["Section"]))
    this.section = "";
    else
    this.section = this.Request.QueryString["Section"];

    if (this.IssueName() == "Issue003" || this.IssueName() == "Issue004" || this.IssueName() == "Issue005" || this.IssueName() == "Issue006")
    {
    if (this.User.Identity.IsAuthenticated && (

    this.User.IsInRole("Administrators") ||
    this.User.IsInRole("Issue003") || this.User.IsInRole("Issue004") || this.User.IsInRole("Issue005") || this.User.IsInRole("Issue006") ||
    this.User.IsInRole("Subscriber")))
    {
    ;
    }
    else
    {
    //String page = System.Web.HttpContext.Current.Request.Url.AbsoluteUri; // this.GetCurrentPageName();
    this.RequestLogin();
    //Response.Redirect("~/Subscribe.aspx");
    //throw new SecurityException("You are not allowed to edit existent articles!");
    }
    }

    /* Execute */
    this.LoadJavaScript();
    /* Execute */ ( is this where the problem is and the line below. Right now getting errors as they are trying open page-o1.jpg files instead of page-01html files.)

    }

    private void LoadJavaScript()
    {
    String javaScript = "";

    javaScript += LoadFile("~/Issues/" + this.IssueName() + "/JavaScript.js");

    Page.ClientScript.RegisterStartupScript(this.GetType(), "", javaScript, true);
    }


    public String LoadCss()
    {
    return "<style type=\"text/css\"> " + LoadFile("~/Issues/" + this.IssueName() + "/CssStyles.css") + " </style>";
    }

    private String IssueName()
    {
    return "Issue" + ((this.issue < 100) ? "0" : "") + ((this.issue < 10) ? "0" : "") + this.issue.ToString().Trim() + this.section;
    }

    private String LoadFile(String fileName)
    {
    //Open a file for reading
    fileName = Server.MapPath(fileName);

    //Get a StreamReader class that can be used to read the file
    StreamReader objStreamReader = File.OpenText(fileName);

    //Now, read the entire file into a string
    String fileContent = objStreamReader.ReadToEnd();

    objStreamReader.Close();

    return fileContent;
    }

    /*
    protected void Page_Render(object sender, EventArgs e)
    {
    //
    // Insert JavaScript for Image Upload Completed (Flash object will call this function when finished)
    //
    try
    {
    //LinkButton lb = (LinkButton)FormViewItem.Row.FindControl("LinkButtonProcessUpload");
    //LinkButton lb = (LinkButton)RepeaterInfo.Items[0].FindControl("LinkButtonProcessUpload");
    //HiddenField hf = (HiddenField)FormViewItem.Row.FindControl("FlashArguments");
    //HiddenField hf = (HiddenField)RepeaterInfo.Items[0].FindControl("FlashArguments");

    String javaScript = "function UploadComplete() {";

    //javaScript += String.Format("var hiddenFieldObj = document.getElementById('{0}');", hf.ClientID.Replace("_", "$"));
    //javaScript += " if (hiddenFieldObj != null && _args != null)";
    //javaScript += " {";
    //javaScript += " hiddenFieldObj.value = _args;";
    //javaScript += " alert(_args);";
    //javaScript += " }";
    //javaScript += " ";
    javaScript += String.Format("__doPostBack('{0}', '' );", "var a=0;");
    javaScript += "};";

    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "FileCompleteUpload", javaScript, true);
    }
    catch
    { }
    }
    */
    }
    }

    (Here is one page of the html page:)

    <!doctype html>
    <html>

    <head>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <title>Bumples Magazine</title>

    <link rel="stylesheet" href="../Css/MagazineStyles.css" type="text/css" />

    </head>
    <body>
    <div class="fullscreen">

    <div id="atlpg4" class="image"></div>

    <div class="txt mag4-1">
    <h1>Snail</h1>
    <p><br />center; how are you. </p>
    <p><br />center; good </p>
    </div>
    </div>
    </body>
    </html>

    (finally there is a javascript file that runs the whole magazine, which includes words, images and games)

    ///
    // Issue Settings
    //

    var issueNumber = 01;
    var issuePageCount = 4;
    var issuePageHeight = 680;
    var issueNextPage = 1;
    div {
    width: 100%
    }
    // ==

    // Issue Name
    // ==

    Issue_IssueName = function () {
    return "Issue" + ((issueNumber < 100) ? "0" : "") + ((issueNumber < 10) ? "0" : "") + issueNumber.toString();
    };


    //====
    // Load
    //===

    function BmOnLoad() {
    //====
    // settings
    //===

    bmPageWidth = issuePageWidth;
    bmPageHeight = issuePageHeight;
    bmNextPage = issueNextPage;

    var pageUriTemplate = Issue_IssueName() + "/Pages/pages-";

    for (var pg = 1; pg <= issuePageCount; pg++)
    bmPages[pg] = pageUriTemplate + ((pg < 10) ? "0" : "") + pg.toString() + ".jpg";

    BmInitialize();

    //===
    //===

    AddIndexToJumpTo(1, "Cover");
    AddIndexToJumpTo(2, "Contents");
    AddIndexToJumpTo(3, "Letter");
    AddIndexToJumpTo(4, "Old Shail");

    //
    // Page 2 - Contents
    //

    InsertDinamicDiv(2, "", "", 70, 96, 452, 25, "BmFlipTo(1)", "", "", "");
    InsertDinamicDiv(2, "", "", 70, 121, 452, 25, "BmFlipTo(2)", "", "", "");
    InsertDinamicDiv(2, "", "", 70, 152, 452, 25, "BmFlipTo(4)", "", "", "");

    //===========================================================================================
    // Start
    //===========================================================================================

    BmStart();
    BmFlipTo(issueNextPage);
    }

    Hope someone out there can help me.  I am not a programmer and trying to update the old program in  visual studio 2017 c# web forms. Jen

    Tuesday, January 29, 2019 4:45 PM

All replies

  • User36583972 posted

    Hi bumples18,

    <body onLoad="BmOnLoad();">
    <form id="form1" runat="server">
    <div>  (Note can I put the issue in here to open the pages of the html files. If so how.)

    </div>
    </form>

    You can have a div on your page and load the html from an external page into it.

    Please refer the following solutions.

    Load Html Page inside .aspx page
    https://forums.asp.net/t/1560540.aspx?Load+Html+Page+inside+aspx+page

    Loading complete Html-page in contentpane of aspx-page
    https://stackoverflow.com/questions/4928132/loading-complete-html-page-in-contentpane-of-aspx-page


    Best Regards,

    Yong Lu

    Wednesday, January 30, 2019 5:35 AM
  • User-605499000 posted

    Thank you so much for your help. I did research the places and tried them. But, I couldn't get them to work but I also realized that I am looking at the wrong place. Stream reader has to open javacript and html would have stopped that.  I think that the problem is in the javascript folder and I have toload the html file in the javascript folder. I hope that I am correct. Again thanks for the help.

    Jen

    Thursday, January 31, 2019 12:30 AM
  • User36583972 posted

    Thank you so much for your help. I did research the places and tried them. But, I couldn't get them to work but I also realized that I am looking at the wrong place. Stream reader has to open javacript and html would have stopped that.  I think that the problem is in the javascript folder and I have toload the html file in the javascript folder. I hope that I am correct. Again thanks for the help.

    Jen

    Hi bumples18,

    You can try to solve the issue on your side.

    If you have a new question you can start a new thread with all necessary code snippets for anyone else to be able to reproduce your issue from scratch along with a detailed description about the results including any exception messages.

    Thank you for your understanding.

    Best Regards,

    Yong Lu

    Thursday, January 31, 2019 3:11 AM