in

Stuart Manning

Belfast Web Development | C# | ASP.NET | Ajax | LINQ | JQuery | CSS | Flex

ASP.NET

March 2008 - Posts

  • AjaxToolkit - problems rendering in VS2008 - eg. TabContainer

    Never fear, if you like me are having a few problems with the AjaxControl toolkit after installing the VS2008 hotfix, then you can still get VS2005 express editions @

    http://msdn2.microsoft.com/en-us/express/aa975050.aspx

    Link provides downloads for complete express range and required SP1 where required

  • LINQ RSS Writer

    LINQ makes everyday tasks a joy and not a chore. This simple code example was implemented and deployed on http://www.causewaydesign.co.uk/ in 15 mins.

    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.ServiceModel.Syndication;
    using System.Xml;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    
    
    public partial class rss : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
            DataClassesDataContext dataContext = new DataClassesDataContext();
    
    
    
            // Select data
    
            var itemsQuery = from post in dataContext.tbl_causeway_news
                             orderby post.news_date descending
    
                             select new
    
                             {
    
                                 post.news_id,
    
                                 post.news_title,
    
                                 post.news_text,
    
                                 post.news_date,
    
                             };
    
    
    
            // Prepare response
    
            Response.Buffer = false;
    
            Response.Clear();
    
            Response.ContentType = "application/xml";
    
    
    
            // Create an XmlWriter to write the feed into it
    
            using (XmlWriter writer = XmlWriter.Create(Response.OutputStream))
            {
    
                // Set the feed properties
    
                SyndicationFeed feed = new SyndicationFeed
    
                    ("Stuart Manning",
    
                    "Causeway Design - Web Development, Belfast, Northern Ireland",
    
                    new Uri("http://www.causewaydesign.co.uk"));
    
    
    
                // Add authors
    
                feed.Authors.Add(new SyndicationPerson
    
                    ("info@causewaydesign.co.uk",
    
                    "Stuart Manning",
    
                    "http://www.causewaydesign.co.uk"));
    
    
    
    
    
    
    
                // Set copyright
    
                feed.Copyright = new TextSyndicationContent
    
                    ("© Copyright 2005-"+DateTime.Now.Year.ToString()+" Causeway Design");
    
    
    
                // Set generator
    
                feed.Generator = "Causeway Design RSS Generator";
    
    
    
                // Set language
    
                feed.Language = "en-GB";
    
    
    
                // Add post items
    
                List items = new List();
    
                foreach (var Post in itemsQuery)
                {
    
                    SyndicationItem item = new SyndicationItem();
    
                    item.Id = Post.news_id.ToString();
    
                    item.Title = TextSyndicationContent.CreatePlaintextContent(Post.news_title);
    
                    item.Content = SyndicationContent.CreateXhtmlContent(Post.news_text);
    
                    item.PublishDate = Post.news_date.Value.ToUniversalTime();
    
                    //item.Categories.Add(new SyndicationCategory(Post.Category));
    
    
    
                    items.Add(item);
    
                }
    
                feed.Items = items;
    
    
    
                // Write the feed to output
    
                Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(feed);
    
                rssFormatter.WriteTo(writer);
    
    
    
                writer.Flush();
    
            }
    
            Response.End();
    
        }
    }
    
    
    
    
    
    
  • Spam Catch without Captcha - Comment on article by Nannette Thacker

    Nannette Thacker post an article on "Spam Catch without Captcha". http://weblogs.asp.net/nannettethacker/archive/2008/03/16/spam-catch-without-captcha.aspx

    His idea is to use a hidden field that is irresistible to spam bots.

    This is a similar trick that I also use to eliminate spam, where by i place a textbox with a label inside the form. If your doing this, add a little accessibility to the solution.

     

    ASP.NET

    <div style="position: absolute; left: -1000px">

          <asp:Label ID="lbl_spam" runat="server" Text="Required, assuming that only an automated bot will see this. Elsewise, please ignore"></asp:Label>

          <asp:TextBox ID="txt_spam" TextMode="MultiLine" runat="server"></asp:TextBox>

    </div>

    For everyone else:-

    <div style="position: absolute; left: -1000px">
                    <span id=" lbl_spam">Required, assuming that only an automated bot will see this. Elsewise, please ignore
                    <textarea name=" txt_spam" rows="2" cols="20" id="ctl00_cph_main_txt_spam"></textarea></span>
    </div>

    So if your handling the response:

                     txt_spam has content = spam

    Unlike Nannette approach, I prefer to mark the mail and forward it to a dedicated spam account, just in case.

  • IE8, Web Standards and Compatibility

    Leeanne Lowe picked up on an article posted by on JoelonSoftware entitled Martian Headsets. http://www.joelonsoftware.com/items/2008/03/17.html

    Read over this light hearted article that addresses web standards. It's both fact and fun.

    Also watch Dean Hachamovitch presentation and commentary on IE8 @ sessions.visitmix.com - keynote (approx timeline - 27min 40sec).

    Leeanne is the creative force behind the Belfast based Creative Online Media.

    Links:-

    Leeanne Lowe @ http://creative.leeannelowe.com/
    JoelonSoftware @ http://www.joelonsoftware.com article Matian Headset @ http://www.joelonsoftware.com/items/2008/03/17.html
    Creative Online Media @ http://www.creativeonlinemedia.com/

  • Windows Live Writer

    This was a quick message posted into stuartmanning.com using Windows Live Writer 

    Update:- Was impressed by the simplicity of Windows Live Writer. Tried and tested with blogger and community server. Was impressed to set my search tag on the main windows. Handy spell checker and controlled mark-up, even community server can be a bit screwy some days.

    Ideally, I would love to see Live Writer store my details in the cloud, so I can use one tool to manage everything and anywhere. I'm sure there is more to come.

    http://get.live.com/writer/overview