示例#1
0
        /// -----------------------------------------------------------------------------
        ///         ''' <summary>
        ///         ''' Page_Load runs when the control is loaded
        ///         ''' </summary>
        ///         ''' <remarks>
        ///         ''' </remarks>
        ///         ''' <history>
        ///         '''     [cnurse]	9/23/2004	Updated to reflect design changes for Help, 508 support
        ///         '''                       and localisation
        ///         ''' </history>
        ///         ''' -----------------------------------------------------------------------------
        private void Page_Load(System.Object sender, System.EventArgs e)
        {
            try
            {
                // Determine ItemId of Link to Update

                if (Request.QueryString["ItemId"] != null)
                {
                    int.TryParse(Request.QueryString["ItemId"], out itemId);
                }

                // If the page is being requested the first time, determine if an
                // link itemId value is specified, and if so populate page
                // contents with the link details
                if (Page.IsPostBack == false)
                {
                    // Deprecated, implemented below but kept here for some time just for reference
                    // tblGetContent.Visible = System.Security.SecurityManager.IsGranted(new System.Net.WebPermission(System.Net.NetworkAccess.Connect, "http://www.dotnetnuke.com"));
                    var permissionSet = new PermissionSet(System.Security.Permissions.PermissionState.None);
                    permissionSet.AddPermission(new System.Net.WebPermission(System.Net.NetworkAccess.Connect, "http://www.dotnetnuke.com"));
                    tblGetContent.Visible = permissionSet.IsSubsetOf(AppDomain.CurrentDomain.PermissionSet);

                    var roles = RoleController.Instance.GetRoles(this.PortalId);

                    ddlViewOrderLinks.DataSource     = LinkController.GetLinks(this.ModuleId);
                    ddlViewOrderLinks.DataTextField  = "Title";
                    ddlViewOrderLinks.DataValueField = "ViewOrder";
                    ddlViewOrderLinks.DataBind();

                    cblGrantRoles.DataSource     = roles;
                    cblGrantRoles.DataTextField  = "RoleName";
                    cblGrantRoles.DataValueField = "RoleID";
                    cblGrantRoles.DataBind();

                    ClientAPI.AddButtonConfirm(cmdDelete, Services.Localization.Localization.GetString("DeleteItem"));

                    if (itemId != -1)
                    {
                        // Obtain a single row of link information

                        var objLink = LinkController.GetLink(itemId, ModuleId);

                        if (objLink != null)
                        {
                            ddlViewOrderLinks.Items.Remove(ddlViewOrderLinks.Items.FindByText(objLink.Title));

                            if (ddlViewOrderLinks.Items.Count > 0)
                            {
                                ddlViewOrderLinks.SelectedValue = LinkController.GetLinkByHigherViewOrder(objLink.ViewOrder, this.ModuleId).ToString();

                                if (int.Parse(ddlViewOrderLinks.SelectedValue) < objLink.ViewOrder)
                                {
                                    ddlViewOrder.SelectedValue = "A";
                                }
                                else
                                {
                                    ddlViewOrder.SelectedValue = "B";
                                }
                            }

                            txtTitle.Text = objLink.Title.ToString();

                            ctlURL.Url = objLink.Url;

                            // Probably no longer needed
                            //ctlURL.ShowDatabase = true;
                            //ctlURL.ShowSecure = true;

                            // chkGetContent.Checked = objLink.RefreshContent

                            string urlType = LinkController.ConvertUrlType(DotNetNuke.Common.Globals.GetURLType(objLink.Url));

                            if (urlType != "U")
                            {
                                tblGetContent.Visible = false;
                            }

                            txtDescription.Text = objLink.Description.ToString();

                            // If (Common.Utilities.Null.IsNull(objLink.ViewOrder) = False) Then
                            // txtViewOrder.Text = Convert.ToString(objLink.ViewOrder)
                            // End If

                            ddlGetContentInterval.SelectedValue = objLink.RefreshInterval.ToString();

                            ctlAudit.CreatedByUser = objLink.CreatedByUser.ToString();
                            ctlAudit.CreatedDate   = objLink.CreatedDate.ToString();

                            ctlTracking.URL      = objLink.Url;
                            ctlTracking.ModuleID = ModuleId;

                            foreach (ListItem cb in cblGrantRoles.Items)
                            {
                                cb.Selected = objLink.GrantRoles.Contains(";" + cb.Value + ";");
                            }
                        }
                        else
                        {
                            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(), true);
                        }
                    }
                    else
                    {
                        cmdDelete.Visible   = false;
                        ctlAudit.Visible    = false;
                        ctlTracking.Visible = false;
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }