locked
there is no direction for the word request and am I missing a using directive RRS feed

  • Question

  • User-605499000 posted

    I am merging the old file with a new file for a magazine. The code below used to work but not know. Here is the file:  I have tried var and public and private request and it doesn't work Thanks Jen

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using BumpleBooks.Models;


    namespace BumpleBooks.UI
    {

    public partial class Games_Default : BumpleBooks.UI.BasePage
    {

    private Int32 issue = 0;
    private String section = "";

    protected void Page_Load(object sender, EventArgs e)
    {


    if (String.IsNullOrEmpty(this.Request.QueryString["Issue"])) (# Request has the directive problem and if I fix it then the query string is wrong. it is happening on 3 lines)

    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 > 28)
    {
    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() == "Issue001")
    {
    if (this.User.Identity.IsAuthenticated && ( (#error the (use)r has a directive error and if I change it then it says the IsInRole problem
    this.User.IsInRole("Issue001") ||
    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 */
    }

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

    javaScript += LoadFile("~/Games/JavaScript/Movime.js");
    javaScript += LoadFile("~/Games/JavaScript/DivClass.js");
    javaScript += LoadFile("~/Games/JavaScript/TalkingBalloon.js");
    javaScript += LoadFile("~/Games/JavaScript/Magazine.js");
    javaScript += LoadFile("~/Games/JavaScript/PuzzleClass.js");
    javaScript += LoadFile("~/Games/JavaScript/MemoryClass.js");
    javaScript += LoadFile("~/Games/JavaScript/MoveObjectsTo.js");
    javaScript += LoadFile("~/Games/JavaScript/gamet.js");
    javaScript += LoadFile("~/Games/" + 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
    { }
    }
    */
    }

    public class BasePage
    {
    }
    }

    Sunday, November 4, 2018 1:34 AM

Answers

  • User-605499000 posted

    Thank you very much for your help. I did look at the directives and I  changed the default as you suggested  to

    public partial class _Default : Page plus did some other things and the errors have all gone on the page. You are a good programmer and I am not a programmer except in javascrip for my magazine games.  Up dating my website has been really hard but everyone on the forums has been very helpful.

    Thanks again,

    Jen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 5, 2018 6:47 PM

All replies

  • User-271186128 posted

    Hi bumples18,

    I am merging the old file with a new file for a magazine. The code below used to work but not know. Here is the file:  I have tried var and public and private request and it doesn't work

    Do you mean the page not redirect to the code behind class file? If that is the case, please check the Page directive and namespace.

    Code in aspx page (default.aspx):

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="webapps.Webpages.Default" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
            </div>
        </form>
    </body>
    </html>
    

    Code behind (default.aspx.cs)

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace webapps.Webpages
    {
        public partial class Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
        }
    }

    More details, please check the ASP.NET Page Class and ASP.NET Web Forms Page Syntax.

    Besides, you could also add a new web page and copy the content in the partial class to the new page.

    Best regards,
    Dillion

    Monday, November 5, 2018 2:27 AM
  • User-605499000 posted

    Thank you very much for your help. I did look at the directives and I  changed the default as you suggested  to

    public partial class _Default : Page plus did some other things and the errors have all gone on the page. You are a good programmer and I am not a programmer except in javascrip for my magazine games.  Up dating my website has been really hard but everyone on the forums has been very helpful.

    Thanks again,

    Jen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 5, 2018 6:47 PM