Archives

Archives / 2009
  • ASP.NET 4.0 and ClientID Mode

    In this post I will be talking about a new enhancement in ASP.NET 4.0.It is now possible to set the name of your controls ClientID attribute, thanks to the ClientIDMode property. Developers requested a better way of setting names of the web server controls and with the new version of ASP.NET 4.0, this is now a reality.

  • Stored procedures with Linq to Sql in an ASP.Net application


    First we need to create the 3 stored procedures that will insert,update and delete records from the Authors table

    This is not a post on how to create stored procedures, so i am just going to paste here the complete stored procs.

       
          DeleteAuthor

    USE [pubs]
    GO

    SET ANSI_NULLS ON
    GO

    SET QUOTED_IDENTIFIER ON
    GO

    CREATE PROCEDURE [dbo].[DeleteAuthor]

    @AuthorID nvarchar(20)

    AS
    BEGIN

    DELETE FROM authors
    WHERE au_id = @AuthorID

    END
    GO


       
          UpdateAuthor

    USE [pubs]
    GO

    SET ANSI_NULLS ON
    GO

    SET QUOTED_IDENTIFIER ON
    GO

    CREATE PROCEDURE [dbo].[UpdateAuthor]

    @authorID varchar(11),
    @lname nvarchar(50),
    @fname nvarchar(50),
    @phone char(12),
    @address nvarchar(40),
    @city nvarchar(40),
    @state char(2),
    @zip char(5),
    @contract bit

    AS
    BEGIN

    UPDATE authors
    SET

    au_lname=@lname,
    au_fname=@fname,
    phone=@phone,
    address=@address,
    city=@city,
    state=@state,
    zip=@zip,
    contract=@contract
    WHERE au_id  = @authorID

    END
    GO


       
          InsertAuthor

    USE [pubs]
    GO

    SET ANSI_NULLS ON
    GO

    SET QUOTED_IDENTIFIER ON
    GO

    CREATE PROCEDURE [dbo].[InsertAuthor]
    @id varchar(11),
    @lName nvarchar(50),
    @fname nvarchar(50),
    @phone char(12),
    @address nvarchar(40),
    @city nvarchar(40),
    @state char(2),
    @zip char(5),
    @contract bit

    AS
    BEGIN

    INSERT INTO pubs.dbo.authors(
    au_id,
    au_lname,
    au_fname,
    phone,
    address,
    city,
    state,
    zip,
    contract)
    VALUES (
    @id,
    @lname,
    @fname,
    @phone,
    @address,
    @city,
    @state,
    @zip,
    @contract)

    END


    GO

    1) Launch Visual Studio 2008

    2) Create an ASP.net web application. Use C# a your language of development

    3) Name your project – solution as you want.

    4) Open the Server Explorer and connect to the Pubs database.

    5) Add a new item in your project, a Linq to SQL classes, a .dbml file. name it authors.dbml

    6) Drag and drop from the Server explorer window the authors table into the designer area (on the .dbml file)

    7) Right-Click on the designer area and show the “Show methods Pane”

    8) Drag and drop the stored procedures from the Server explorer to the designer area

    9) Select the author entity from the deisgner area and select the Properties window. In theDefault methods we need to assign the correct stored procs and not to leave the default option which is “use Runtime”. So please assign the different methods to their respective stored procs. Have a look at the picture below



    10) We will use these stored procs that are methods now as far as LINQ is concerned to update,insert and delete records from the database.

    11) Add a button in the Default.aspx file. Name it “Update”.Double click on this button. In the event handling routine type:

  • How to build a simple ASP.Net application with C# and Entity Framework

    In this post I will show you a step by step example on how to build an ASP.NET application with C# and Entity Framework. First let’s try to define what EF is and why it is going to help us to create easily data-centric applications.Entity Framework is an object-relational mapping (ORM) framework for the .NET Framework.EF addresses the problem of Object-relational impedance mismatch. I will not be talking about that mismatch because it is well documented in many sites on the Internet. Through that framework we can program against a conceptual application model instead of programming directly against a relational schema-model. By doing so we can decrease the amount of code we do write to access a data storage and thus decrease maintenance time.

  • About Me

    My name is Nikolaos Kantzelis, I am 34 years old and I come from Greece. I am based in Athens.I work as a freelance web and application's developer focusing on .Net Technologies.I also work as a Microsoft Certified Trainer and I usually train software engineers on ASP.NET,WCF,WPF and SQL Server.I am also an ASP.Net MVP.

  • How to create,use and manipulate a web user control

    User controls are reusable controls that can be defined once and used whenever we need them, in any of the .aspx pages of our application. We do have skins,themes and css to give a standard look to our website. User controls help to achieve that as well because since we define them once and use many times, thus making sure we do not have same controls on pages looking differently. When we make changes to a user control all these changes will be reflected to all instances of the control.