Exemple #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Cookies["LoggedInCookie"] == null || (Request.Cookies["LoggedInCookie"] != null && Request.Cookies["LoggedInCookie"]["LoggedIn"] != "true"))
        {
            Response.Redirect("Register.aspx");
        }

        if (!Page.IsPostBack)
        {
            //Set the events for the image button
            SubmitImgBtn.Attributes.Add("onmouseout", "this.src = 'Resources/Images/SubmitDefault.png'");
            SubmitImgBtn.Attributes.Add("onmouseover", "this.src = 'Resources/Images/SubmitMouseOver.png'");

            //Databind the dropdown list
            //Open a new instance of the class containing the genrelist
            //Store as an arraylist
            ArrayCollections getlist   = new ArrayCollections();
            ArrayList        genreList = getlist.GenreList();
            //Remove "All" from the arraylist since it is not a genre
            genreList.Remove("All");

            //Set source and databind
            GenreDdl.DataSource = genreList;
            GenreDdl.DataBind();
        }

        //Set the gridviews select command to only bring up books that the user has rated
        SqlDataSource1.SelectCommand = "SELECT TOP 4 [BookImageUrl] , [BookId] , [BookName] FROM [BookInformation] WHERE [BookSubmiterId] = '" + Request.Cookies["LoggedInCookie"]["UserId"] + "'";

        //Hide the details panel
        BookDetailsPnl.Visible = false;
    }
Exemple #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Used to databind the dropdownlist with the book genres
        ArrayList DdlGenreArray = new ArrayList();

        //Check the cookies to see if the user is loggedin otherwise redirect to Register.aspx
        if (Request.Cookies["LoggedInCookie"] == null || (Request.Cookies["LoggedInCookie"] != null && Request.Cookies["LoggedInCookie"]["LoggedIn"] != "true"))
        {
            Response.Redirect("Register.aspx");
        }

        //Check if the page has been loaded before
        if (!Page.IsPostBack)
        {
            //Add mouseenter/mouseover events to the image buttons
            FindYesBtn.Attributes.Add("onmouseover", "this.src = 'Resources/Images/YesMouseOver.jpg'");
            FindYesBtn.Attributes.Add("onmouseout", "this.src = 'Resources/Images/YesDefault.jpg'");

            FindNoBtn.Attributes.Add("onmouseover", "this.src = 'Resources/Images/NoMouseOver.jpg'");
            FindNoBtn.Attributes.Add("onmouseout", "this.src = 'Resources/Images/NoDefault.jpg'");

            //Databind items to the DropDownList (DdlGenere) using an ArrayCollection
            ArrayCollections getlist = new ArrayCollections();
            DdlGenreArray       = getlist.GenreList();
            DdlGenre.DataSource = DdlGenreArray;
            DdlGenre.DataBind();
        }
    }
Exemple #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Check the cookies to see if the user is loggedin otherwise redirect to Register.aspx
        if (Request.Cookies["LoggedInCookie"] == null || (Request.Cookies["LoggedInCookie"] != null && Request.Cookies["LoggedInCookie"]["LoggedIn"] != "true"))
        {
            Response.Redirect("Register.aspx");
        }

        //Check if the page has been loaded before
        if (!Page.IsPostBack)
        {
            //Add mouseenter/mouseover events to the image buttons
            FindYesBtn.Attributes.Add("onmouseover", "this.src = 'Resources/Images/YesMouseOver.jpg'");
            FindYesBtn.Attributes.Add("onmouseout", "this.src = 'Resources/Images/YesDefault.jpg'");

            FindNoBtn.Attributes.Add("onmouseover", "this.src = 'Resources/Images/NoMouseOver.jpg'");
            FindNoBtn.Attributes.Add("onmouseout", "this.src = 'Resources/Images/NoDefault.jpg'");

            //Databind items to the DropDownList (DdlGenere) using an ArrayCollection
            //Used to databind the dropdownlist with the book genres
            ArrayList DdlGenreArray = new ArrayList();
            //DataBind the dropdownlist by getting the list from the ArrayCollections class
            ArrayCollections getlist = new ArrayCollections();
            //Get the list
            DdlGenreArray = getlist.GenreList();
            //Apply the source
            DdlGenre.DataSource = DdlGenreArray;
            //DataBind
            DdlGenre.DataBind();

            //Open a new instance of the bookWormService
            Service BookWormService = new Service();
            //Execute the query against the database on the service (Man, I love APIs)
            MainGridView.DataSource = BookWormService.ExecuteQuery("SELECT [BookId], [BookName], [BookImageUrl], [BookAuthor], [BookAverageRating] FROM [BookInformation] ");
            //Databind the gridView
            MainGridView.DataBind();
            //Dispose of the Service Resources
            BookWormService.Dispose();
        }
    }