Contents tagged with ASP.NET

  • Azure User Group meeting in Montreal


    If you are an ASP.NET dev and still wondering about Azure, the cloud offering from Microsoft, this is a presentation you don’t want to miss!!


    “Top Azure features every ASP.NET developer should know about”
    This meeting will be presented by Bill Wilder, MVP Azure from Boston, USA.


    When: Monday, April 28, 2014
    Where: Microsoft Montreal office (2000 McGill College, 4th floor, Montreal, QC)
    Cost: Free for existing members, 5$ for visitors


    To RSVP, visit

  • “Time-Saving VS11 and ASP.NET 4.5 Features You Shouldn’t Miss” ebook by Telerik

    Here is a nice opportunity offered by Telerik:

    They have created this amazing new ebook that you can download for free.
    More than that, you don’t even need to register to download the pdf, so it is free free!

    What’s inside ?

    • Intellisense help you discover JS and CSS features
    • WAI Aria makes the web usable by all
    • HTML5 and CSS3 are available out of the box
    • WebAPI exposes data via HTTP service
    • Strongly Typed Data Binding ensures runtime confidence
    • Request Validation prevents yellow screens of death
    • Page Inspector puts an end to layout headaches

    Download it here:
    Free E-book: Time-Saving VS11 and ASP.NET 4.5 Features You Shouldn’t Miss


    I strongly recommend this reading, you will not loose your time and will learn something new for sure!

  • Microsoft Certified Professional Developer: ASP.NET 3.5

    Back from vacation I’ve just received an email to say I earn my Microsoft Certified Professional Developer: ASP.NET Developer 3.5 certification (70-564), which I took in beta back in November 08. As an MCT that gives me the opportunity to teach more Microsoft courses (MOC).

    Interested in beta exams ?
    Read this:
    Pros: it is free
    Cons: No material or preparation content available…

    So after 70-536 and 70-562 this ends my .NET 3.5 certification path.

    I think next one will be WCF.

    Note: Please do not contact me for 70-564 preparation material or link request as I went there with no preparation (beta).

  • ASP.NET Dynamic Data: Customize a template field

    Following my first post on ASP.NET Dynamic Data, I want to show you that you can customize existing fields used by Dynamic Data very easily.

    With the Northwind db, here is the generated edit screen for the Employees table:


    We could make this default user experience a lot better by changing the date input, why not add some AJAX here ?

    Template fields used by Dynamic Data are stored in DynamicData/FieldTemplates folder as simple user controls:

    You can see that there is a DateTime_Edit.ascx control, open it and add an Image for the calendar icon and a CalendarExtender from the ASP.NET AJAX Control Toolkit.

    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
    <asp:TextBox ID="TextBox1" runat="server" CssClass="droplist" Text='<%# FieldValueEditString %>' Columns="20" /> 
    <asp:Image ID="imgCalendar" runat="server" ImageUrl="~/DynamicData/Content/Images/calendar.png" />
    <ajax:CalendarExtender runat="server" TargetControlID="TextBox1" PopupButtonID="imgCalendar" />

    Now you get:

    The calendar looks weird due to some CSS applied to the DetailsView. A quick workaround is to remove the CssClass attribute from the DetailsView1 control in DynamicData/PageTemplates/Edit.aspx :

    Doing that (or fixing the CSS in Site.css file) will make the calendar looks good:

    Note that the field is still fully functional without adding code, in a next post I will show how to create a new template field.

    Source code:


    Technorati Tags:
  • Customizing ASP.NET Dynamic Data

    From Wikipedia: “ASP.NET Dynamic Data is a web application scaffolding framework from Microsoft, shipped as an extension to ASP.NET, that can be used to build data driven web applications.

    So if you use VS2008 and .NET 3.5 SP1 you can take advantage of ASP.NET Dynamic Data to quickly create a full administration website (UI and CRUD) over a model (LINQ To SQL or better Entity Framework) on top of some db tables, and all this in about 3 minutes!

    Furthermore the system is very flexible and you can customize the look and feel of the generated web pages through a set of pages and user controls available on the DynamicData folder.

    But the default “3 minutes” experience create a web app that exposes CRUD operations on every tables/every columns…

    Default screen while editing the products table:

    What you may want to customize:

    • Prevent some tables to be “scaffolded”
    • Change table display name
    • Format columns data
    • Hide some columns (like Ids)

    This is the part where you’ll need to write a bit of code. In App_Code folder create new file that will hold several partial class to provides metadata information. You need to add 2 class for each entities in your model, one partial class with the name of the entity, and one sub-class to set metadata. The second one is “attached” to your entity class with the MetadataType attribute.

    C# snippet for Products entity:

    public partial class Products
        [TableName("Company products")]
        public class Products_Metadata
            public object ProductID { get; set; }
            public object ProductName { get; set; }
            [DisplayName("Price"),DisplayFormat(DataFormatString = "{0:c}")]
            public object UnitPrice { get; set; }
            public object UnitsInStock { get; set; }
            public object ReorderLevel { get; set; }
            public object Discontinued { get; set; }
            public object QuantityPerUnit { get; set; }
            public object UnitsOnOrder { get; set; }
            public object Suppliers { get; set; }
            public object Order_Details { get; set; }

    To remove a table, use the ScaffoldTable(false) attribute.

    Products table will now appear as “Company products” (TableName attribute).
    I keep only 4 columns and rename them (ScaffoldColumn and DisplayName attributes).
    Price column is formatted as currency (DisplayFormat attribute).

    See the result:


    Technorati Tags:
  • ASP.NET Dynamic Data Web projects templates

    Since Visual Studio 2008 SP1 you may have noticed 2 projects template for dynamic data:

    Dynamic Data Web Site - Dynamic Data Entities Web Site

    So what is the difference ?

    • Dynamic Data Web Site / Dynamic Data Web Application:
      Uses a LINQ to SQL model and LinqDataSource controls.
    • Dynamic Data Entities Web Site / Dynamic Data Entities Web Application:
      Uses a ADO.NET Entity Data Model and EntityDataSource controls.

    Since LINQ to SQL is dead I would not recommend using Dynamic Data Web templates. LINQ to Entities is now the recommended data access solution and will remain in .NET 4.0, so for your RAD Scaffolding needs you should use Dynamic Data Entities Web Site/Web Application!

  • Certified ASP.NET 3.5!

    I completely forgot as I did this in beta 3 months ago… that was a surprise this morning to get a notification that I earned the Microsoft Certified Technology Specialist: .NET Framework 3.5, ASP.NET Application Development competency (exam 70-562).

    Certifications are not important for anyone, but for me as an MCT I need to be certified to teach training, so this one is good for Visual Studio 2008 courses!

    The 70-562 exam should be available to public in august 2008.

    The preparation guide is already visible here:

  • Load a txt file in a TextBox

    Here is a very simple piece of C# code to load a text file in a TextBox. Typical use to display a disclaimer

    [Update 1: added using statement for the StreamReader]

    protected void Page_Load(object sender, EventArgs e)
        if (!Page.IsPostBack)
            using (StreamReader StreamReader1 =
                new StreamReader(Server.MapPath("disclaimer.txt")))
                txtDisclaimer.Text = StreamReader1.ReadToEnd();

    [Update 2: use the new File.ReadAllText() wrapper for StreamReader, exact same thing, but 1 line of code instead of 3...]

    protected void Page_Load(object sender, EventArgs e)
        if (!Page.IsPostBack)
            txtDisclaimer.Text =
    File.ReadAllText(Server.MapPath("disclaimer.txt")); } }

    FYI here is the static ReadAllText method in Reflector:

    Then you could add a CheckBox to enable a Postback Button (disabled by default):

    <input id="cbAgree" type="checkbox" onclick="ManageBtnGoState();" />
    <label for="cbAgree" style="font-weight:bold; color:Red;">
    I Agree with the present statement</label>
    <asp:Button ID="btnGo" runat="server" Text="Take Survey"
    onclick="btnGo_Click" Enabled="false" />

    And the Js function:

    <script type="text/javascript">
    function ManageBtnGoState()
        $get('<%= btnGo.ClientID %>').disabled = 'disabled';  
        if ( $get("cbAgree").checked == true )
        {    $get('<%= btnGo.ClientID %>').disabled = '';  }

    Note that $get() is a function from the ASP.NET AJAX client framework. If you don't have it please use document.getElementById() instead.


    Another solution

    Load the txt file from Resource.

    First add the text file as Resource in a resx file of your project (here common.resx):


    You can event have one file per language!

    Then the code looks like:

    protected void Page_Load(object sender, EventArgs e)
        if (!Page.IsPostBack)
            txtDisclaimer.Text = Resources.Common.disclaimer_en;

    You could add a check for the current culture and load the corresponding disclaimer file.

  • [Cool Tool] VS Resource Refactoring Tool

    The recently opened Visual Studio Gallery contains some free hidden Microsoft gems, Resource Refactoring Tool is one of them.

    Resource Refactoring Tool provides developers an easy way to extract hard coded strings from the code to resource files. It works with C# and VB.Net in all project types that ships with Visual Studio 2005 and 2008.

    After installed, in code editor just click a string and select Refactor / Extract to Resource.

    A preview window shows changes, finds other instances of the text being replaced in the project, list existing similar resource items to avoid duplicate entries and automatically replaces hard coded string with a reference to the new resource item, nice!


    Resource Refactoring Tool Download link: