in

Dot Net Mafia

Group site for developer blogs dealing with (usually) .NET, SharePoint 2013, SharePoint 2010, Office 365, SharePoint Online, and other Microsoft products, as well as some discussion of general programming related concepts.

This Blog

Syndication

Archives

Corey Roth [MVP]

A SharePoint MVP bringing you the latest time saving tips for SharePoint 2013, Office 365 / SharePoint Online and Visual Studio 2013.

May 2005 - Posts

  • Breaking Changes

    Although there are not a lot of breaking changes in the new framework, there are a few.  If you care to review the document containing the changes, it is located here.
     
     
     
  • UrlMappings

    This is a great new feature of ASP.NET 2.0.  How many times have you needed to redirect one URL to another?  Maybe redirect a static url to another url to another page with an ID?  The new urlMappings element in the web.config allows you to do just this.  Take a look at this example below.
     
    <urlMappings enabled=“true”>
        <add url=“~/LAX.aspx” mappedUrl=“~/local/index.aspx?LocationCode=LAX” />
        <add url=“~/specials/walmart.aspx” mappedUrl=“~/specials/9994.aspx” />
    </urlMappings>
     
    The first entry maps LAX.aspx to the local site page with a LocationCode query string parameter of LAX.  The second maps the page walmart.aspx to 9994.aspx (Remember the ~ operator maps to the root of the web application).  This will be extremely useful in search engine placement in the future.  It will also allow us to make custom urls for customers without having to do special Rhythmyx publishing configurations.
  • SetFocusOnError Property

    Another new property added to validator controls is the SetFocusOnError property.  This new property allows a developer to force focus on the control that did not pass validation.  This will be an excellent imrpovement for forms such as Blue Chip enrollment.  To force the focus, simply set the SetFocusOnError property to true.
     
    <asp:TextBox ID="TextBox3“ runat="server“ />
     
    <asp:RequiredFieldValidator  SetFocusOnError="true"
     ErrorMessage="TextBox3 is empty"   ControlToValidate="TextBox3"
     runat="server“/>

  • Machine.config

    The machine.config has been trimmed down quite a bit in Beta 2.  Take a look at the attached file.  A lot of this is because the browser caps have been moved into the browsers folder underneath the config folder.  Any how, you might look at the attached file and see how it varies.
  • BONUS TIP! Avalon and Indigo Beta 1 RC

    I know it sounds like this stuff is so far off that you will never use it, but Avalong and Indigo have entered Beta.  These technologies will significantly change the way clients talk to server applications in the future.  If you are interested in downloading it, go to the URL below.
     
     
     
  • Namespaces in ASP.NET and Referencing Controls

    Today's article is particularly important because if you don't know this you will have trouble getting controls to work in ASP.NET 2.0.  As I have mentioned in the past Web Applications do not use namespaces any longer.  Any class placed in the App_Code folder can be used globally throughout the web site.  This does not include controls.  A control can now no longer see another control unless a reference has specifically been added in the markup to that control (even if it is in the same folder).  This is a bad time and I have been complaining a lot to Microsoft about it. 
     
    For example, if you have the VehicleDetails control and you want to load the VehicleDetailsSubControl at runtime, you must incude a reference such as the following in your markup.
     
    <%@ Register Src="vehicledetailssubcontrol.ascx" TagName="vehicledetailssubcontrol" TagPrefix="uc6" %>
    In this case, I don't think that the TagName and TagPrefix are required since the control is loaded at runtime.  If the above line is not included, the control will not show up in IntelliSense even if you manually include a namespace.  It will not compile.
     
    This also applies when inheriting from a control.  If you want to inherit from the BaseControl, you must include a register directive for it to compile.
     
    Unfortunately, the Migarion Wizard does not currently add these register directives automatically.  However, after talking to Scott Guthrie, they may be taking care of this for us.
  • ASP.NET Development Helper

    Once of the Developement Leads on the ASP.NET team has come out with a great tool that will aid in debugging ASP.NET 2.0 code.  It functions as an IE plugin and will allow you to examine the contents of ViewState and the Cache.  It looks pretty cool and I think it will prove to be pretty helpful as we start working with ASP.NET 2.0 more.
     
    It's available at:
     
  • More Videos

    If you are looking for some more training videos.  Some new ones have been posted on how to do stuff with Visual Web Developer 2005.  They cover everything from getting started to databinding.
     
     
     
  • Device Filtering

    The label control now allows you to output different text based upon browser type.  This could prove to be a powerful feature when there are browser specific differences. 
     
    For example:
     
    <asp:label id="MyLabel" runat="server"
          text="Default Text"
          mozilla:text="Hippie Browser"
          ie:text="Not Hippie Browser" />
     
    In Firefox, it would display Hippie Browser.  In IE, it would display Not Hippie Browser.  Supposedly, you can specify this on just about any property now on any control.
     
    Browser capabilities are now stored in .browser files in the %windows%\Microsoft.NET\Framework\version\CONFIG\Browsers folder.  By default, there are browser profiles for IE, Mozilla, Opera, AvantGo, WebTV, and a ton of device specific ones (phones).
  • Asynchronous Pages

    Asynchronous support has always been avaialble to ASP.NET through the use of HTTP Handlers, but those can be quite the bad time.  Now, ASP.NET 2.0 makes it really easy.  Start by adding the following to your compiler directive.
     
    <%@ Page Async='True" ... %>
     
    Then sometime before the page's OnPreRenderComplete event (refer to the new Page LifeCycle), you register a begin and end method.  To do this you call the Page object's AddOnPreRenderCompleteAsync method and pass in delegates pointing to the methods for begin and end.
     
    For example
     
    protected void OnLoad(object sender, EventArgs e)
    {
        AddOnPreRenderComplete(new BeginEventHandler(BeginAsyncOperation), new EndEventHandler(EndAsyncOperation));
    }
     
    Your begin and end methods then start their asynchonous operations.  This could be data access, or whatever you might want to do asynchronously.
  • ASP.NET Version Switcher

    I have discovered that the new ASP.NET tab in the IIS MMC seems to be broken after you have had a previous version of the framework installed.  So this handy tool makes switching versions of the framework for an application just as easy.  You don't have to assemble any long command line strings any more.  Use it if you have ASP.NET version issues.
     
     
  • Our 100th Tip of the Day! Control State

    I can't believe we have 100 tips out there now.  Hopefully someone is reading this and finding it some what useful.  I am hoping these tips will be a useful reference when we start using 2.0 more and more. 
     
    A new way of maintaining state is available through something called Control State.  Although Control State is not nearly as convenient to use (i.e.: ViewState[IsMarcusLame] = true).  It still can be very useful for controls.  Technically, control state is still stored in the same View Sstate string, but the difference is control state can not be disabled (even when viewstate is disabled by the page or application).   
     
    I said it is less convenient and here is why.  For a control to use Control State, it must make a call to the RegisterRequiredControlState method of the Page object in the OnInit override.   Secondly you must override the LoadControlState and SaveControlState events to manually get your objects out of the control state.  That is truly the part that sucks.
     
    Here is a simple example, of the amount of code that is required just to store one field.
     
    public class SampleControl : Control
    {
      string color = "black";
      protected override void OnInit(EventArgs e)
      {
        Page.RegisterRequiresControlState(this);
        base.OnInit(e);
      }
      protected override void LoadControlState(
                              object savedState)
      {
        object[] state = (object[])savedState;
        base.LoadControlState(state[0]);
        color = (string)state[1];
      }
      protected override object SaveControlState()
      {
        object[] state = new object[2];
        state[0] = base.SaveControlState();
        state[1] = color;
        return state;
      }
    }
     
    As you can see, it requires quite a bit of code to make it happen.  So this might not be ideal, but it is at least a good idea for you to know its out there.
     
  • SiteMap

    Microsoft decided to introduce in ASP.NET 2.0 what we built a long time ago when we relaunched our web site.   A new file web.sitemap has been added which contains a links and title to various pages on your sites.  The file can be set up in a hierarchy just like our navigation which allows you to build things like breadcrumbs automatically. 
     
    A sitemap file could look like this.
     
    <siteMap>
      <siteMapNode title="Home" url="~/default.aspx" >
        <siteMapNode title="Introduction to ASP.NET" url="~/introduction/default.aspx">
        <siteMapNode title="What's New in Whidbey?" url="~/introduction/whatsnew.aspx"/>
          <siteMapNode title="Sample Applications (Starter Kits)" url="~/introduction/starterkits.aspx"/>
          <siteMapNode title="Introduction to Visual Web Developer" url="~/introduction/vwd.aspx"/>
        </siteMapNode>
      </siteMapNode>
    </siteMap>
     
    Three new controls have been introduced that make use of this new web.sitemap file.  SiteMapPath can be used to make breadcrumbs.  Menu can be used to make basic javascript/dhtml menus but it is fully customizable.  Lastly, TreeView will allow a user to browse to any node in the siteMap similar to the type of tree control they use in MSDN Subscriber downloads.
  • vshost.exe

    When developing the Alert Server I noticed that there is always this process running when I have Visual Studio running.  It had a file name of <application name>.vshost.exe (in this case Cdog.Smoking.Windows.Server.vshost.exe).  I did some research to find out what it is and this is what I found out.  It is a process designed to reduce startup time of a .NET application, evalue Visual Basic expressions at design-time (that's you Marcus), and debug ClickOnce applications.
  • Code Snippet Editor

    One of the coolest new features in Visual Studio actualy came from VB.  The code snipet editor allows you to write custom code snippets with variables inside them and autoamtically insert them into your code by typing a keyword.  Now, it is easy to create your own by using the new Code Snippet Editor.  Unfortunately, you have to write these new snippets in VB (Marcus will be so excited).  Check it out here if you have Beta 2 installed.
     
More Posts Next page »
2015 dotnetmafia.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems