Inhoud blog
  • ASP.NET - Asynchronous call to a webservice with impersonation
  • ASP.NET - Custom object as parameter for ObjectDataSource
  • ASP.NET - Identity impersonation
  • MyCalendar - add events without postbacks
  • ASP..NET Web Parts
    Zoeken in blog

    My Profile
  • LinkedIn
  • My Favorite Blogs
  • Kevin DeRudder
  • Rudi Larno
  • David Hayden
  • David Cumps
  • Reinout's blog
    Talking about new features, useful things, frustrations in .NET and so on...
    11-08-2007
    Klik hier om een link te hebben waarmee u dit artikel later terug kunt lezen.ASP.NET Error handling

    Error handling is one of the most important (and maybe least enjoying) things to do while developing.

    Most of the times error-prone methods will contain try/catch blocks to prevent the exception from slipping through. There might still be some unhandled exceptions though, in code blocks not "protected" by a try/catch block. Those can be handled on page or on application level.

    Now let's see an example, writing the error to the trace (so it can be viewed and further investigated by a developer using a trace listener) in case of page level error handling and navigating to a user defined error page in case of application level exception handling.

    On page level :

        protected void Page_Error(object sender, EventArgs e)
        {
            // Retrieve the last error and write to the trace
            Trace.Write(Server.GetLastError());
            // Clear the last error
            Server.ClearError();
       
    }

    On application level :

        void Application_Error(object sender, EventArgs e)
        {
            // Navigate to a user defined error page
            Server.Transfer("HandleError.aspx");
            // Make sure to call Server.GetLastError() and Server.ClearError() in the error handling page
       
    }

    11-08-2007 om 23:19 geschreven door Reinout Waelput  


    Klik hier om een link te hebben waarmee u dit artikel later terug kunt lezen.ASP.NET Navigation

    There are different ways to navigate to a different URL, including :
    Response.Redirect(“url”);
    Server.Transfer(“url”, false); 

    What's the difference?
    With Response.Redirect you will not be able to access data from the original page through the PreviousPage property, by using Server.Transfer (or the PostBackUrl property) you will be able to do so.

    11-08-2007 om 23:02 geschreven door Reinout Waelput  


    Klik hier om een link te hebben waarmee u dit artikel later terug kunt lezen.SQL 2005 : get comma separated list
    Ever wanted to return a comma seperated list of values with a query, struggling with functions or cursors ?
    In SQL 2005, there's an easy/short solution for this.

    e.g. to return the name of a company and a comma separated list of e-mail addresses of the users in the company.

    SELECT c.company_name,
            mail = STUFF
                    (
                    (
                        SELECT ‘, ‘ + u.mail_address as [text()]
                          FROM t_User u
                    INNER JOIN t_Company co ON u.company_id = co.company_id
                         WHERE co.company_id = c.company_id
                       FOR XML Path (‘’)
                    ),
                    1,
                    2,
                    ‘’
                    )
      FROM t_Company c

    The STUFF() function removes - in this example - the first 2 characters in the list, to avoid starting the list with a comma followed by a space.
    Text() maps the list to a text node.
    For a description of "FOR XML Path", I refer to the MSDN documentation : http://msdn2.microsoft.com/en-us/library/ms345137.aspx

    11-08-2007 om 21:14 geschreven door Reinout Waelput  


    Klik hier om een link te hebben waarmee u dit artikel later terug kunt lezen.New blog !
    Some people keep asking me when I start blogging again. Yes again, since our first "blogging project" (used to be known as webbullogs) didn't last very long.

    The purpose of this blog is to explain a bit what I'm busy with (mostly .NET related) - which will also allow me to remember some things a little longer ;-) - and some other useful (and at times extremely useless) stuff.

    Hopefully you will enjoy reading it ... and maybe even learn something from it !

    11-08-2007 om 20:33 geschreven door Reinout Waelput  




    Archief per week
  • 03/09-09/09 2007
  • 27/08-02/09 2007
  • 20/08-26/08 2007
  • 13/08-19/08 2007
  • 06/08-12/08 2007
  • 26/09-02/10 2005

    E-mail mij

    Druk op onderstaande knop om mij te e-mailen.



    Blog tegen de wet? Klik hier.
    Gratis blog op https://www.bloggen.be - Meer blogs