Blog posts


  • Insert and delete with LINQ to SQL

    September 17, 2010 | Tags: C#, LINQ, Snippet
    Needed to remove all old posts associated with a specific user and then add new posts. With a DataSet, this could be done by fetching the data, clear it and then add the new posts. A simular way is possible in LINQ-to-SQL:
    CalendarDataContext db = new CalendarDataContext();
    List<int> categories = new List<int>() // ..with some data of course

    // Get current posts
    IQueryable<SubscriptionSetting> settings = db.SubscriptionSettings.Where(s => s.UserId == username);

    // Delete all old posts
    db.SubscriptionSettings.DeleteAllOnSubmit(settings);

    // Add new
    foreach (int c in categories) {
    db.SubscriptionSettings.InsertOnSubmit(new SubscriptionSetting() { UserId = username, CategoryId = c });
    }

    db.SubmitChanges();

  • Excel in .NET without OLEDB/COM

    September 13, 2010 | Tags: ASP.NET, Open source, C#
    This seems to be a neat open source library to read, create and modify Excel spreadsheets in your .NET project without using OLEDB or COM:

    http://code.google.com/p/excellibrary/

    Currently only support the traditional .xls (BIFF8) format.

  • OutputCache don't work and how to solve it

    September 12, 2010 | Tags: ASP.NET, C#, Troubleshooting
    So, you've added something like:
    <%@ OutputCache Duration="10" VaryByParam="*" %>
    But still your code runs and your breakpoints are reached, eventhough they shouldn't as you've just added server side caching!

    Well, the most likely issue is that you break the response way to soon by using Response.End().

    Remove the Response.End() and your caching should most likely begin to work as you intended.

    Want to know more about why this is an issue with caching? Rick Strahl writes about it in his article: Don’t use Response.End() with OutputCache

  • jQuery intellisense in visual studio 2008

    September 09, 2010 | Tags: Javascript, ASP.NET, jQuery
    Scott Guthrie has posted a three step guide how to enable intellisense completion for jQuery within Visual Studio, check it out at his blog:
    http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx

  • Thickbox and jQuery 1.4

    September 03, 2010 | Tags: Troubleshooting, jQuery
    Need to get Thickbox working with a newer version of jQuery, like 1.4? Then all you need to do is to remove one character from the script file.

    Open jquery.thickbox.js , search for @rel and remove the @.

    What the original code looks like:
    var imageGroup = $("a[@rel="+rel+"]").get();
    What it should look like when you've removed the @:
    var imageGroup = $("a[rel="+rel+"]").get();
    Please note that if you're using a minified version of Thickbox your code could look a bit different. But you can always search for "@rel".

    Credits where credits due, original post by ABOUTQ