+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / User Control asp:button not showing in test page

User Control asp:button not showing in test page

1 posts, 0 answered
  1. Laurence
    Laurence avatar
    7 posts
    Registered:
    20 Feb 2013
    11 Mar 2013
    Link to this post

    Hi there, 

    This is following a reply with and instruction from a support ticket this morning.

    I was given the following code to try and eliminate our problem on 5.4 where we are unable to publish/edit any pages that are 'sent to approval':

    var manager = PageManager.GetManager();

           var
    collection = manager

               .GetPageDataList()

               .Where(x => x.Status == ContentLifecycleStatus.Temp)

               .ToList();

                  

           foreach (var item in collection)

           {

               manager.DeleteItem(item);

               manager.SaveChanges();

           }

    We have amended this code to try and work on a asp:button instead of pageload. Here is the backend code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Sitefinity.Modules.Pages;
    using Telerik.Sitefinity.GenericContent.Model;

    namespace SitefinityWebApp.UserControls.Saville
    {
        public partial class FunctionDeleteTemporaryPages : System.Web.UI.UserControl
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                Response.Write("Show");
            }
            protected void btnCleanPages_Click(object sender, EventArgs e)
            {
                var manager = PageManager.GetManager();
                var collection = manager
                    .GetPageDataList()
                    .Where(x => x.Status == ContentLifecycleStatus.Temp)
                    .ToList();
                foreach (var item in collection)
                {
                    lblPages.Text = String.Format("{0}{1}", item.ToString(), Environment.NewLine);
                    manager.DeleteItem(item);
                    manager.SaveChanges();
                }
                lblPageOutput.Text = String.Format("{0}", collection.Count.ToString());
            }
        }
    }

    Front end Code: 

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="FunctionDeleteTemporaryPages.ascx.cs" Inherits="SitefinityWebApp.UserControls.Saville.FunctionDeleteTemporaryPages" %>

    <h1>Hello</h1>
    <div>
        <label title="Pages Deleted:"></label>
        <asp:Label runat="server" ID="lblPageOutput"></asp:Label>
        <asp:Label runat="server" ID="lblPages"></asp:Label>
        <asp:Button runat="server" ID="btnCleanPages" Text="Submit" OnClick="btnCleanPages_Click" />
    </div>
        

    The UserControl within our webapp was successfully built but when it comes to viewing the page we are not seeing any of the output apart from the Response.Write("show");

    ANy ideas as I have trawled the internet for hours looking for answers?

     

    Regards

     

     

1 posts, 0 answered