-[Danny Chen]- Blog of an ASP.NET QA tester

Tips and info about Site Navigation, ImageMap, Menu and other cool ASP.NET v2.0 features.

  • I have a new blog: http://blogs.msdn.com/dannychen

    The ASP.NET weblogs are still using .Text which, frankly, is a bit annoying to work with and just plain 'old'.  Pete LePage showed me the MSDN blogs which use the (much newer) Community Server 2.0 codebase so I'm going to switch to it.  They look much cooler anyway.  Hopefully my blog will still be syndicated on ASP.NET so the readers can keep up to date with my happenings.

    Read more...

  • IE7 Beta and VWD Style Builder.

    There's a bug in the IE7 beta which seems to break the style builder.  Of course we'll work on getting it fixed but in the meantime, if you happen to have IE7 installed, there's a workaround you can apply.

    Read more...

  • Top results for the loading control challenge.

    Thank you everyone for sharing your code with me.  There were quite a few excellent submissions and I learned a few things.  Here are the top entries I received so far for the challenge.  I'll add to this list if any more come in that I feel are worth mention.

    Read more...

  • Custom Control Challenge - Entry #1

    Credit goes to:  crms -at- sina.com

     
    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    namespace TestCode
    {
        [
    ToolboxData("<{0}:WaitCursor runat=server></{0}:WaitCursor>")]
        
    public class WaitCursor : Control
        {
            
    protected override void OnInit(EventArgs e)
            {
                
    //only allow one waiting for each page
                if (HttpContext.Current.Items["Waiting"] == null)
                {
                    Page.Response.Write(
    @"<div id='myid'

    style='width:100%;height:100%;z-index:9999;background-color:white'>loading...</div>"
    );
                    Page.Response.Write(
    @"<script language='javascript'>
    var c = document.getElementsByName('myid')[0];
    c.style.display='';
    var t = null;
    var m = function()
    {
    if(document.readyState == 'complete')
    {
    c.style.display = 'none';
    clearInterval(t);
    }
    }

    //maybe we should make the interval configurable

    t = setInterval(m,100);
    </script>
    "
    );

                    Page.Response.Flush();

                    
    HttpContext.Current.Items["Waiting"] = "yes";
                }
            }
        }
    }

    Read more...

  • We are Hiring.

    Do you want to help make ASP.NET and Visual Studio even better in the next version?  We are looking for the brightest and the most talented candidates to fill some challenging positions in our team.  If you think you have the skills, guts, and determination to help improve the lives of web developers and shape web technology for the future, follow this link and submit your resume.

    Read more...

  • A custom control challenge - make a page loading control that just works.

    It is a fairly well known technique to use Response.Buffer and Response.Flush to make a "please wait" or "Loading..." message appear when you know a page is going to take a while to load.  So I was quite estatic when I read on ScottGu's blog that someone (Daniel Fisher) had done what I've wanted to do for a while: formalize this trick into a nice tidy custom control you can just drop onto a page.  You can see it here:  http://www.lennybacon.com/PleaseWaitBuildingAWaitScreenControlForASPNET.aspx.  It is really a very slick control.  However, there was one problem I couldn't (and still can't) figure out which stopped me from writing this control initially.  When I look more closely at Daniel's code, I noticed that he hadn't solved this problem either.

    Read more...

  • Saving unicode content with encoding

    Here's a quick tip that you may or may not know about.  In Visual Studio (and possibly other MS programs) it's not enough to paste some unicode content into your file and then hit save.  You'll also need to save it with the correct encoding.  However, once you save the file with a particular encoding, it will continue to use that encoding until you switch it (this means you won't have to keep doing this for each save)

    Read more...

  • Making the CompiledTemplateBuilder work for you. Create a Template Library.

    This is a bit of a follow on to my last post.  At the end, I made an update about how to make use of custom TreeNodes in a databound scenario.  I did that example with the CSSTreeNode instead of the TemplatedTreeNode because the custom property in the templated case was an ITemplate.  Trying to assign a value to that property is a great deal more difficult than a string property.  And that got me thinking...

    Read more...

  • Code Listing for 1/27/2006

    TemplateLibrary.cs
     
    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Collections.Generic;

    namespace MSSamples
    {
        
    /// <summary>
        /// TemplateLibrary - custom control that holds a list of templates
        ///   This control provides a way to store an arbitrary list of templates
        /// provided declaratively to it through mark-up.  The templates are
        /// made accessible through a property to any other object that needs them
        /// </summary>
        
        [
    ParseChildren(true,"Templates"), PersistChildren(false)]
        
    public class TemplateLibrary : Control
        {
            
    public TemplateLibrary()
            {
                _templates =
    new TemplateList();
            }
            
            
    private TemplateList _templates;
            [
    PersistenceMode(PersistenceMode.InnerProperty)]
            
    public TemplateList Templates
            {
                
    get
                {
                    
    return _templates;
                }
            }

        }

        
    // The List<TemplateItems> so that a string indexer
        // can also be used to reference items.  (This isn't
        // the most efficient running algorithm, but I don't
        // expect a significantly large number of items to
        // end up in the list and it is memory efficient.)
        public class TemplateList : List<TemplateItem>
        {
            
    public TemplateItem this[string key]
            {
                
    get
                {
                    
    foreach (TemplateItem ti in this)
                    {
                        
    if (string.Compare(key, ti.Name, StringComparison.InvariantCultureIgnoreCase) == 0)
                            
    return ti;
                    }
                    
    return null;
                }
            }
        }

        
    // Template object - contains a template and a name
        public class TemplateItem : ITemplate
        {
            
    private string _name;
            
    private ITemplate _template;

            
    public string Name
            {
                
    get { return _name; }
                
    set { _name = value; }
            }

            
    // The Template
            // Since it isn't "known" what the exact type of container
            // will be used to instantiate a template, I just assume all
            // of them will implement the IDataItemContainer interface,
            // which is a good idea anyway for containers.
            [PersistenceMode(PersistenceMode.InnerProperty),
            
    TemplateContainer(typeof(IDataItemContainer))]        
            
    public ITemplate Template
            {
                
    get { return _template; }
                
    set { _template = value; }
            }

            
    // This is just to help reduce one level of dereferencing
            // needed to get a handle on the template object.
            #region ITemplate Members
            
    public void InstantiateIn(Control container)
            {
                Template.InstantiateIn(container);
            }
            #endregion
        }
    }

    Read more...