Example #1
0
        //*******************************************************
        //
        // The Page_Load event handler on this User Control is used to
        // obtain a DataReader of link information from the Links
        // table, and then databind the results to a templated DataList
        // server control.  It uses the ASPNetPortal.LinkDB()
        // data component to encapsulate all data functionality.
        //
        //*******************************************************

        private void Page_Load(object sender, System.EventArgs e)
        {
            // Set the link image type
            if (IsEditable)
            {
                linkImage = "~/images/edit.gif";
            }
            else
            {
                linkImage = "~/images/navlink.gif";
            }

            // Obtain links information from the Links table
            // and bind to the list control
            ASPNetPortal.LinkDB links = new ASPNetPortal.LinkDB();

            myDataList.DataSource = links.GetLinks(ModuleId);
            myDataList.DataBind();

            // Ensure that only users in role may add links
            if (PortalSecurity.IsInRoles(ModuleConfiguration.AuthorizedEditRoles))
            {
                EditButton.Text        = "Add Link";
                EditButton.NavigateUrl = "~/DesktopModules/EditLinks.aspx?mid=" + ModuleId.ToString();
            }
        }
Example #2
0
        //****************************************************************
        //
        // The DeleteBtn_Click event handler on this Page is used to delete
        // a link.  It  uses the ASPNetPortal.LinksDB()
        // data component to encapsulate all data functionality.
        //
        //****************************************************************

        private void DeleteBtn_Click(Object sender, EventArgs e)
        {
            // Only attempt to delete the item if it is an existing item
            // (new items will have "ItemId" of 0)

            if (itemId != 0)
            {
                ASPNetPortal.LinkDB links = new ASPNetPortal.LinkDB();
                links.DeleteLink(itemId);
            }

            // Redirect back to the portal home page
            Response.Redirect((String)ViewState["UrlReferrer"]);
        }
Example #3
0
        //****************************************************************
        //
        // The Page_Load event on this Page is used to obtain the
        // ItemId of the link to edit.
        //
        // It then uses the ASPNetPortal.LinkDB() data component
        // to populate the page's edit controls with the links details.
        //
        //****************************************************************

        private void Page_Load(object sender, System.EventArgs e)
        {
            // Determine ModuleId of Links Portal Module
            moduleId = Int32.Parse(Request.Params["Mid"]);

            // Verify that the current user has access to edit this module
            if (PortalSecurity.HasEditPermissions(moduleId) == false)
            {
                Response.Redirect("~/Admin/EditAccessDenied.aspx");
            }

            // Determine ItemId of Link to Update
            if (Request.Params["ItemId"] != null)
            {
                itemId = Int32.Parse(Request.Params["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)
            {
                if (itemId != 0)
                {
                    // Obtain a single row of link information
                    ASPNetPortal.LinkDB links = new ASPNetPortal.LinkDB();
                    IDataReader         dr    = links.GetSingleLink(itemId);

                    // Read in first row from database
                    dr.Read();

                    TitleField.Text       = (String)dr["title"];
                    DescriptionField.Text = (String)dr["description"];
                    UrlField.Text         = (String)dr["url"];
                    MobileUrlField.Text   = (String)dr["mobileurl"];
                    ViewOrderField.Text   = dr["vieworder"].ToString();
                    CreatedBy.Text        = (String)dr["createdbyuser"];
                    CreatedDate.Text      = ((DateTime)dr["createddate"]).ToShortDateString();

                    // Close datareader
                    dr.Close();
                }

                // Store URL Referrer to return to portal
                ViewState["UrlReferrer"] = Request.UrlReferrer.ToString();
            }
        }
Example #4
0
        //*******************************************************
        //
        // The Page_Load event handler on this User Control is used to
        // obtain a DataReader of link information from the Links
        // table, and then databind the results to a templated DataList
        // server control.  It uses the ASPNetPortal.LinkDB()
        // data component to encapsulate all data functionality.
        //
        //*******************************************************

        private void Page_Load(object sender, System.EventArgs e)
        {
            // Set the link image type
            if (IsEditable)
            {
                linkImage = "~/images/edit.gif";
            }
            else
            {
                linkImage = "~/images/navlink.gif";
            }

            // Obtain links information from the Links table
            // and bind to the datalist control
            ASPNetPortal.LinkDB links = new ASPNetPortal.LinkDB();

            myDataList.DataSource = links.GetLinks(ModuleId);
            myDataList.DataBind();
        }
Example #5
0
        //****************************************************************
        //
        // The UpdateBtn_Click event handler on this Page is used to either
        // create or update a link.  It  uses the ASPNetPortal.LinkDB()
        // data component to encapsulate all data functionality.
        //
        //****************************************************************

        private void UpdateBtn_Click(Object sender, EventArgs e)
        {
            if (Page.IsValid == true)
            {
                // Create an instance of the Link DB component
                ASPNetPortal.LinkDB links = new ASPNetPortal.LinkDB();

                if (itemId == 0)
                {
                    // Add the link within the Links table
                    links.AddLink(moduleId, itemId, Context.User.Identity.Name, TitleField.Text, UrlField.Text, MobileUrlField.Text, Int32.Parse(ViewOrderField.Text), DescriptionField.Text);
                }
                else
                {
                    // Update the link within the Links table
                    links.UpdateLink(moduleId, itemId, Context.User.Identity.Name, TitleField.Text, UrlField.Text, MobileUrlField.Text, Int32.Parse(ViewOrderField.Text), DescriptionField.Text);
                }

                // Redirect back to the portal home page
                Response.Redirect((String)ViewState["UrlReferrer"]);
            }
        }