protected void Page_Load(object sender, EventArgs e)
    {
        if (!QueryHelper.ValidateHash("hash", "activityid") || Parameters == null)
        {
            return;
        }

        pnlGen.GroupingText     = GetString("om.activity.details.groupgeneral");
        pnlComment.GroupingText = GetString("om.activity.activitycomment");
        btnView.ImageUrl        = GetImageUrl("/Design/Controls/UniGrid/Actions/View.png");
        btnContact.ImageUrl     = GetImageUrl("Design/Controls/UniGrid/Actions/contactdetail.png");

        // Get the ORDER BY column and starting event ID
        string orderBy = ValidationHelper.GetString(Parameters["orderby"], "ActivityID DESC");

        if (orderBy.IndexOf(';') >= 0)
        {
            orderBy = "ActivityID DESC";  // ORDER BY with semicolon is considered to be dangerous
        }
        string whereCondition = ValidationHelper.GetString(Parameters["where"], string.Empty);
        int    contactId      = ValidationHelper.GetInteger(Parameters["contactid"], 0);
        bool   isMerged       = ValidationHelper.GetBoolean(Parameters["ismerged"], false);
        bool   isGlobal       = ValidationHelper.GetBoolean(Parameters["isglobal"], false);

        isSitemanager = ValidationHelper.GetBoolean(Parameters["issitemanager"], false);

        // Get activity ID from query string
        activityId = QueryHelper.GetInteger("activityid", 0);

        LoadData();

        // Initialize next/previous buttons
        int[] prevNext = ActivityInfoProvider.GetPreviousNext(activityId, whereCondition, orderBy, contactId, isMerged, isGlobal);
        if (prevNext != null)
        {
            prevId = prevNext[0];
            nextId = prevNext[1];
            btnPrevious.Enabled = (prevId != 0);
            btnNext.Enabled     = (nextId != 0);
            btnPrevious.Click  += btnPrevious_Click;
            btnNext.Click      += btnNext_Click;
        }

        // Set button caption
        btnNext.Text     = GetString("general.next") + " >";
        btnPrevious.Text = "< " + GetString("general.back");

        // Enable text boxes and show save button if user is autorized to change activities
        userIsAuthorized = CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.ContactManagement", "ManageActivities");
        if (userIsAuthorized)
        {
            btnSave.Visible   = true;
            btnSave.Click    += new EventHandler(btnSave_Click);
            txtURL.ReadOnly   = false;
            txtTitle.ReadOnly = false;
        }

        // Disable collapse of toolbar (IE7 bug)
        txtComment.ToolbarCanCollapse = false;

        RegisterScripts();
        btnStamp.OnClientClick = "AddStamp('" + txtComment.ClientID + "'); return false;";
    }