Beispiel #1
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();
        }
    }