User Control asp:button not showing in test page

Posted by Community Admin on 04-Aug-2018 17:04

User Control asp:button not showing in test page

All Replies

Posted by Community Admin on 11-Mar-2013 00:00

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("01", 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

 

 

This thread is closed