All pastes #286893 Raw Edit

Stuff

public text v1 · immutable
#286893 ·published 2006-12-20 23:53 UTC
rendered paste body
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using Caradonna;

public partial class DisplayDestination : System.Web.UI.Page
{
    protected Destination.DestinationsDataTable destinationCollection;
    protected Destination.DestinationsRow currentDestination;


    protected void Page_PreInit(object sender, EventArgs e)
    {
        //!! HOW CAN WE DO THIS GLOBALLY

        destinationCollection = Adapters.Destinations.GetByCode(Request.QueryString["d"]);
        currentDestination = destinationCollection[0];
        //this.Theme = currentDestination.Theme;
        this.Theme = "Caribbean";
    }
    
    protected void Page_Init(object sender, EventArgs e)
    {



        HtmlMeta keywordsMeta = new HtmlMeta();
        keywordsMeta.Name = "keywords";
        keywordsMeta.Content = currentDestination.PageKeywords;

        HtmlMeta descriptionMeta = new HtmlMeta();
        descriptionMeta.Name = "description";
        descriptionMeta.Content = currentDestination.PageDescription;

        Page.Title = currentDestination.PageTitle;

        Page.Header.Controls.Add(keywordsMeta);
        Page.Header.Controls.Add(descriptionMeta);

    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadDestinationPhotos();

            //== Events
            Article.ArticlesDataTable eventCollection = Adapters.Articles.GetByRegionId(2, currentDestination.DestinationId);
            
            if (eventCollection.Rows.Count == 0)
            {
                DestinationEventsArea.Visible = false;
            }
            else
            {
                DestinationEvents.DataSource = eventCollection;
            }

            DataBind();

            //Page.DataBind();

            Asset.AssetsDataTable assetTypeCollection = Adapters.Destinations.GetTypesByDestinationId(currentDestination.DestinationId);
            Asset.AssetsRow assetTypeCollection = assetTypeCollection[0];
            
            AssetTab2.Visible = true;
        }
    }

    private void LoadDestinationPhotos()
    {
        string path = Server.MapPath("../assets/photos") + "\\Destinations\\" + currentDestination.Code + "\\";
        string[] files = Directory.GetFiles(path, "*.jpg");

        for (int i = 0; i < files.Length; i++)
        {

            Image image = new Image();
            image.ImageUrl = "~/assets/photos/destinations/" + currentDestination.Code + "/" + Path.GetFileName(files[i]);
            image.Width = Unit.Pixel(244);
            image.AlternateText = currentDestination.Title;
            image.ToolTip = currentDestination.Title;

            DestinationPhotoArea.Controls.Add(image);
            // DestinationPhotoArea.Controls.Add(new LiteralControl("<br />"));

            if (i != files.Length - 1)
                DestinationPhotoArea.Controls.Add(new LiteralControl("<br />"));

        }
    }

}