More in this section

Forums / Developing with Sitefinity / View News Letter

View News Letter

7 posts, 0 answered
  1. Cyril Wasem
    Cyril Wasem avatar
    20 posts
    Registered:
    04 Aug 2009
    22 Sep 2009
    Link to this post
    Hi.

    How i can create à control to view all newsletter on my web site.

    Cyril
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    22 Sep 2009
    Link to this post
    Hi Cyril Wasem,

    Below is  a sample implementation that illustrates desired behavior. We use RadGrid control bound to dataManager.GetNewsletters() list.

    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" GridLines="None" Skin="Black" AllowPaging="true" PageSize="20"
    <MasterTableView> 
     <Columns> 
         <telerik:GridBoundColumn DataField="Subject"  HeaderText="Subject"/> 
         <telerik:GridBoundColumn DataField="Status"  HeaderText="Status"/> 
         <telerik:GridBoundColumn DataField="Content"  HeaderText="Content"/>  
         <telerik:GridBoundColumn DataField="DateCreated"  HeaderText="DateCreated"/>   
     </Columns> 
    </MasterTableView> 
    </telerik:RadGrid> 

    DataManager man = new DataManager(); 
    IList allNewsLetters = man.GetNewsletters(); 
    RadGrid1.DataSource = allNewsLetters; 
    RadGrid1.DataBind(); 

    I hope this helps.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Cyril Wasem
    Cyril Wasem avatar
    20 posts
    Registered:
    04 Aug 2009
    22 Sep 2009
    Link to this post
    Hi,

    thk's it's work.
    But i have an other question.

    it's possible tu use à "Repeater" to view a list of my newsletter and it's possible to filter to views only the sended newsletters betweed two date ?

    Best regards.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    22 Sep 2009
    Link to this post
    Hello Cyril Wasem,

    DataManager methods does not support filtering. In your custom control you can create if loops and add the INewsletter items to a list. You can expose several properties so that you can use them instead of hardcoding values as these one for the dates.

    Sample code:

            DataManager man = new DataManager(); 
            IList allNewsLetters = man.GetNewsletters(); 
            foreach (INewsletter letter in allNewsLetters) 
            { 
                if (letter.Status.Equals("Sent") && letter.SendDate <= DateTime.Now && letter.SendDate >= DateTime.Now.AddDays(-10)) 
                { 
                    IList<INewsletter> newList = new IList<INewsletter>(); 
                    newList.Add(letter); 
                } 
     
            } 

    Finally you need to bind the repater to the newly created list.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Cyril Wasem
    Cyril Wasem avatar
    20 posts
    Registered:
    04 Aug 2009
    23 Sep 2009
    Link to this post
    Thk's it's work
    but i have another bug.

    I show the content of my newsletter but not on the god format you can see here. ?


    I can't define a width.?

    best regard:

    using System; 
    using System.Data; 
    using System.ComponentModel; 
    using System.Configuration; 
    using System.Collections; 
    using System.Collections.Generic; 
    using System.Web; 
    using System.Web.Security; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using System.Web.UI.WebControls.WebParts; 
    using System.Web.UI.HtmlControls; 
    using Telerik.Security; 
    using Telerik.Notifications.Newsletters; 
    using System.Text; 
    using Telerik.Notifications; 
    using Telerik.Newsletters; 
    using Telerik.Web.UI; 
    using Telerik; 
    using Telerik.Cms.Web.UI; 
     
    public partial class Sitefinity_UserControls_ViewNewsLetter : System.Web.UI.UserControl 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            string newsletter =""
            if (Request.QueryString["email"] != string.Empty) 
            { 
                newsletter = Request.QueryString["idnesletter"]; //"ccf0ec2a-0ee7-4048-bf6f-c33cc454f554";   
            } 
            this.ContNewsLettre.Text = ""
            string sautligne = Convert.ToChar(10).ToString() + Convert.ToChar(13).ToString();  
            DataManager man = new DataManager(); 
            IList allNewsLetters = man.GetNewsletters(); 
            List<INewsletter> newnewList =  new List<INewsletter>(); 
            foreach (INewsletter letter in allNewsLetters) 
            { 
                if ( letter.NewsletterId.ToString() ==  newsletter ) 
                { 
                    newnewList = new List<INewsletter>(); 
                    newList.Add(letter); 
                } 
     
            } 
            thisthis.ContNewsLettre.Text = this.ContNewsLettre.Text + "<tr>" + sautligne; 
            thisthis.ContNewsLettre.Text = this.ContNewsLettre.Text + " <td>" + sautligne; 
            thisthis.ContNewsLettre.Text = this.ContNewsLettre.Text + newList[0].SendDate.ToShortDateString(); 
            thisthis.ContNewsLettre.Text = this.ContNewsLettre.Text + " </td>" + sautligne; 
            thisthis.ContNewsLettre.Text = this.ContNewsLettre.Text + " <td colspan=\"2\">" + sautligne; 
            thisthis.ContNewsLettre.Text = this.ContNewsLettre.Text + newList[0].Subject.ToString(); 
            thisthis.ContNewsLettre.Text = this.ContNewsLettre.Text + " </td>" + sautligne; 
            thisthis.ContNewsLettre.Text = this.ContNewsLettre.Text + " </tr>" + sautligne;  
     
            thisthis.ContNewsLettre.Text = this.ContNewsLettre.Text + "<tr>" + sautligne; 
            thisthis.ContNewsLettre.Text = this.ContNewsLettre.Text + " <td class=\"Contenu\"><div class=\"divcont\">" + sautligne; 
            thisthis.ContNewsLettre.Text = this.ContNewsLettre.Text + newList[0].Content.ToString(); 
            thisthis.ContNewsLettre.Text = this.ContNewsLettre.Text + "</div> </td>" + sautligne; 
            thisthis.ContNewsLettre.Text = this.ContNewsLettre.Text + " </tr>" + sautligne;  
     
        } 
     

  6. Cyril Wasem
    Cyril Wasem avatar
    20 posts
    Registered:
    04 Aug 2009
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    23 Sep 2009
    Link to this post
    Hello Cyril Wasem,

    You can use Repeater/ RadGrid or another appropriate control as suggested in the previous post. These controls have several embedded skins that can be extended as well. This will be better than hardcoding some html.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
7 posts, 0 answered