Blog ( Of Ryan Olshan)

Recent Posts

News

About Ryan Olshan

LinkedIn Profile

Follow Ryan via twitter

Join StrongTypes - Free Generics Help By Email
Join StrongTypes

Community Credit Winner

View my MVP profile

The posts on this weblog are provided "as is" with no warranties and confer no rights. The opinions expressed herin are my own personal opinions and do not represent my employer's view in any way.

Subscribe to Rolog via My AOL
Subscribe to Rolog via Bloglines


Subscribe to Rolog via Feedburner

Furl Rolog




Subscribe to Rolog via Newsburst


Subscribe to Rolog via Pluck

Add Rolog to Technorati Favorites




Thycotic Secret Server

Receive Email Updates


.NET Websites

  • => StrongTypes.com <=
  • Community Credit
  • DotNetCharity.com
  • DotNetSlackers
  • EasyListBox
  • LearnAsp.com
  • SystemNetMail.com
  • SystemWebMail.com

Blogroll

  • Alex Campbell
  • Carlos Magalhaes
  • Charles Carroll
  • Chris Taylor
  • Darren Neimke
  • David Betz
  • Eric Smith
  • Rob Caron
  • Rob Howard
  • Sam Gentile
  • Scott Guthrie
  • Scott Mitchell
  • Tess
  • Wesner Moise
  • Jason Alexander
  • Bill Ryan
  • Steve Smith
  • Sahil Malik
  • David Silverlight

Other Websites

  • 911 Pigeon Alert
  • Pacific Wildlife Project

Strong Coder Bloggers

  • Dean Fiala
  • Doug Nelson
  • Kevin Jones

Yahoo! Groups

  • => StrongTypes <=
  • AspNet2
  • AspNet20GridView
  • PayPalDevDotNet
  • RubyOnRails
  • VSTS

Sunday, December 25, 2005 - Posts

VB.NET 2.0 XML Comments

.NET 2.0 introduces XML comments to VB.NET 2.0. An XML comment starts with ''' (3 single quotes). While this is new to VB.NET 2.0, XML comments have been a supported feature of C# since version 1.0. On a side note, C# XML comments start with ///.

'''
''' I'm a VB.NET XML comment
'''

Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted: Dec 25 2005, 09:48 PM by Ryan Olshan | with no comments
Filed under:
Refactoring made easy in Visual Studio 2005
One of the key features that I like most in Visual Studio 2005 is the built-in support for refactoring. This is how easy it is to extract a method. Visual Studio takes care of all the "dirty" work.

Highlight and right-click the code you want to extract to a method and select Refactor > Extract Method .



Enter the name you want to assign the extracted method.



Visual Studio extracts the method and makes all the necessary name changes, including method signatures (if applicable).

Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted: Dec 25 2005, 09:23 PM by Ryan Olshan | with no comments
Filed under:
MasterPage Property Woes

For some reason I'm not able to access public properties that I declare in a MasterPage, even though it is supposed to work. So, I discovered a way around it was to use FindControl. The example below demonstrates accessing a Literal control with an ID of litText in a MasterPage file.

VB.NET
Dim lit As Literal
lit = Me .Master.FindControl( "litText" )

C#
Literal lit;
lit = ( Literal ) this .Master.FindControl( "litText" );

Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted: Dec 25 2005, 08:47 PM by Ryan Olshan | with no comments
Filed under:
HttpContext Helper

Need to access an HttpContext object in a class, but can't because the class doesn't inherit System.Web.UI.Page? Here is a simple helper class that will allow you to access some of the most common HttpContext objects.

C#
using System;
using System.Web;
using System.Web.Caching;
using System.Web.SessionState;

///


///
Encapsulates all HTTP-specific information about an individual HTTP request.
///
public class HttpContextHelper
{
   ///
   /// Gets the System.Web.HttpApplicationState object for the current HTTP request.
   ///
   public static HttpApplicationState CurrentApplication
   {
      get { return HttpContext .Current.Application; }
   }

   ///
   /// Gets the System.Web.Caching.Cache object for the current HTTP request.
   ///
   public static Cache CurrentCache
   {
      get { return HttpContext .Current.Cache; }
   }

   ///
   /// Gets the System.Web.HttpRequest object for the current HTTP request.
   ///
   public static HttpRequest CurrentRequest
   {
      get { return HttpContext .Current.Request; }
   }

   ///
   /// Gets the System.Web.HttpResponse object for the current HTTP response.
   ///
   public static HttpResponse CurrentResponse
   {
      get { return HttpContext .Current.Response; }
   }

   ///
   /// Gets the System.Web.HttpServerUtility object that provides methods used in
   /// processing Web requests.
   ///
   public static HttpServerUtility CurrentServer
   {
      get { return HttpContext .Current.Server; }
   }

   ///
   /// Gets the System.Web.SessionState.HttpSessionState object for the current
   /// HTTP request.
   ///
   public static HttpSessionState CurrentSession
   {
      get { return HttpContext .Current.Session; }
   }
}

VB.NET
Imports System
Imports System.Web
Imports System.Web.Caching
Imports System.Web.SessionState

'''


''' Encapsulates all HTTP-specific information about an individual HTTP request.
'''

Public
Class HttpContextHelper
   '''
   ''' Gets the System.Web.HttpApplicationState object for the current HTTP request.
   '''

   Public Shared ReadOnly Property CurrentApplication() As HttpApplicationState
      Get
         Return HttpContext.Current.Application
      End Get
   End Property

    '''
   ''' Gets the System.Web.Caching.Cache object for the current HTTP request.
   '''

   Public
Shared ReadOnly Property CurrentCache() As
Cache
      Get
         Return HttpContext.Current.Cache
      End Get
   End Property

    '''
   ''' Gets the System.Web.HttpRequest object for the current HTTP request.
   '''
   
   Public
Shared ReadOnly Property CurrentRequest() As
HttpRequest
      Get
         Return HttpContext.Current.Request
      End Get
   End Property

    '''
   ''' Gets the System.Web.HttpResponse object for the current HTTP response.
   '''

   
Public Shared ReadOnly Property CurrentResponse() As HttpResponse
      Get
         Return HttpContext.Current.Response
      End Get
   End Property

    '''
   ''' Gets the System.Web.HttpServerUtility object that provides methods used in
    ''' processing Web requests.
   '''

   Public Shared ReadOnly Property CurrentServer() As HttpServerUtility
      Get
         Return HttpContext.Current.Server
      End Get
   End Property

    '''
   ''' Gets the System.Web.SessionState.HttpSessionState object for the current
    ''' HTTP request.
   '''

   
Public Shared ReadOnly Property CurrentSession() As HttpSessionState
      Get
         Return HttpContext.Current.Session
      End Get
   End Property
End
Class
Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted: Dec 25 2005, 03:44 PM by Ryan Olshan | with no comments
Filed under: , ,
More Posts