Jack @ ASP.NET

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries for the ‘Visual Studio’ Category

Issue with Auto-Generated Designer Files not Adding Controls: Hotfix available

A hotfix is now available for issues most commonly described as "Controls are not being recognized in the code-behind" and "Editing existing .aspx regenerates .aspx.designer.(cs), but most of the controls are now missing”.

This hotfix can be downloaded from: http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=27117

The update addresses the following Connect bugs:

    * Cannot embed standard asp.net controls in Ajax Control Toolkit TabContainer
    * Controls in CreateUserWizard WizardStep not visible as before
    * issue with auto-generated Designer files not addding components
    * Code Generation in 2010 RC doesn’t work the same as 2008 for ASP.NET Application
    * Editing existing .aspx regenerates designer.cs (good) but most of the controls are now missing (bad)
    * ASP.NET designer fails to auto-generate fields
    * Bug in generating the designer.cs file in VS2010 (Converting VS2008 project to VS2010)

  • Digg
  • DZone
  • Yahoo Buzz
  • Delicious
  • Reddit
  • StumbleUpon
  • SmakNews
  • Jumptags
  • Ping
  • Share/Bookmark

Polyglot Programming Languages in .NET

A polyglot is a computer program or script written in a valid form of multiple programming languages, which performs the same operations or output independently of the programming language used to compile or interpret it.

Generally polyglots are written in a combination of C (which allows redefinition of tokens with a preprocessor) and a scripting programming language such as Lisp, Perl or sh.

For the past few years, many industry leaders were saying that developers needed to know multiple languages. They were right, because learning multiple languages (if done correctly) meant that you needed to learn different programming idioms: procedural programming, object oriented programming, functional programming, and so on.

But that’s painful. Why should I need to learn new syntax to use new idioms? Curly braces aren’t allowed in FP? semicolons aren’t permitted in dynamic languages?

Instead, why can’t a general purpose programming language support multiple programming idioms? C#, VB.NET, and C++ are starting to seriously support that. (Other languages may be doing this as well; I don’t know). All these languages have added (or are adding) lambda expressions which support functional programming concepts. (C++ has used Class Type Functors for this purpose for some time). C# is adding support for dynamic typing (as is VB.NET, in a more strict fashion than previously supported). Implicit typing is supported in C#, C++, and VB.NET as well.

This trend will continue as more and more developers want to use the best programming idiom for a particular task without learning a totally different syntax. Any programming language that calls itself a “general purpose language” will support multiple idioms.

  • Digg
  • DZone
  • Yahoo Buzz
  • Delicious
  • Reddit
  • StumbleUpon
  • SmakNews
  • Jumptags
  • Ping
  • Share/Bookmark

Add New Iterations in TFS

Do you know how to add new iterations in TFS, than, when add new work items, we can select the newly created iterations.

image

Required Permissions

To perform this procedure, you must be a member of the Project Administrators security group for the team project. You cannot explicitly set the necessary security permissions for this procedure. For more information, see Team Foundation Server Permissions.

To modify the team project iterationsTFS_New_Iteration
  1. On the Team menu, point to Team Project Settings, and then click Areas and Iterations.

  2. On the Areas and Iterations dialog box, click the Iterations tab.

  3. Use the toolbar buttons to change the current iteration:

    • Click Add a child node to add a new node under the currently selected node.

    • Click Delete node to delete the currently selected node. In the Delete Nodes dialog box, select the new path for the items to reference, and then click OK.

    • Click Move a node up amongst its siblings to promote the currently selected node higher in the tree.

    • Click Move a node down amongst its siblings to demote the currently selected node lower in the tree.

    • Click Make the selected node a child of its preceding sibling to make the currently selected node a child of the node immediately above it.

    • Click Make the selected node a sibling of its parent to make the currently selected node a peer of the node immediately above it.

  4. Click Close.

 

At last, pay attentions, the name of an iteration node cannot:

  • Contain more than 255 characters.

  • Contain Unicode control characters.

  • Contain any one of the following characters: \ / $ ? * : " & > < # % |

  • Be a system reserve name such as prn, com1, com2, com3, com4, com5, com6, com7, com8, com9, com10, lpt1, lpt2, lpt3, lpt4, lpt5, lpt6, lpt7, lpt8, lpt9, nul, con, aux.

  • Be one of the following characters: “.” or “..

  • Be characters considered invalid by the local file system. For example, Windows-based desktop operating systems might consider the following characters to be invalid if used in the path name: ASCII/Unicode characters 1 through 31, quotation mark ("), less than (<), greater than (>), pipe (|), backspace (\b), null (\0) and tab (\t).

  • Have a total path length greater than 4000 characters.

  • Have a total hierarchy depth of more than 14 levels.

  • Digg
  • DZone
  • Yahoo Buzz
  • Delicious
  • Reddit
  • StumbleUpon
  • SmakNews
  • Jumptags
  • Ping
  • Share/Bookmark

List(T).BinarySearch in C#

I think most of us are quite familiar with binary search. Binary search is an algorithm for locating the position of an element in a sorted list by checking the middle, eliminating half of the list from consideration, and then performing the search on the remaining half.If the middle element is equal to the sought value, then the position has been found; otherwise, the upper half or lower half is chosen for search based on whether the element is greater than or less than the middle element. The method reduces the number of elements needed to be checked by a factor of two each time, and finds the target value, if it exists in logarithmic time. A binary search is a dichotomy divide and conquer search algorithm.

In C#, .Net provide a List<T>.BinarySearch Method (T) which can be used easily. here is a demo:

   1: // Init a long type list

   2: var myList = new List<long>();

   3: foreach (var item in "269, 361, 347, 355, 352, 346, 351, 354".Split(','))

   4: {

   5:     myList.Add(long.Parse(item.Trim()));

   6: }

   7:  

   8: // sort

   9: myList.Sort();

  10: var ret = myList.BinarySearch(347);

  11: Console.WriteLine(ret);

Note, I have a ‘myList.Sort();’ before call the BinarySearch, why? It is because BinarySearch will Search the entire sorted System.Collections.Generic.List<T> for an element using the default comparer and returns the zero-based index of the element.

Yes, it is sorted list that binary search will operate on! So remember make your list sorted before call binary search function

  • Digg
  • DZone
  • Yahoo Buzz
  • Delicious
  • Reddit
  • StumbleUpon
  • SmakNews
  • Jumptags
  • Ping
  • Share/Bookmark

Top 10 Favorite Visual Studio Shortcuts

Use shortcuts can increase your development speed and save you lots of times. These are some of my favorite and most used shortcuts in visual studio, I only list 10 of them, hope it is useful.

  1. Holding down the Ctrl key -  while the completion list is displayed makes the list partially transparent.

  2. Ctrl + – and the opposite Ctrl + Shift + -  To move the cursor back or forward to the last position without having to scroll or switch  files.

  3. Shift+Alt+Enter Switches to Full Screen Mode

  4. Ctrl+K, Ctrl+C Comment a block,   Ctrl+K, Ctrl+U Uncomment the block

  5. Shift + Alt + F10 then Enter expands the smart tag to insert a using statement or implement an Interface

  6. Ctrl+K, Ctrl+D Auto format the file (Source, xml or  html)

  7. Ctrl+M, Ctrl+M – Toggle Outlining Expansion—Based on the current cursor position in the editor window, hides or unhides the outline region.

  8. Ctrl+M, Ctrl+ O Collapses all outlining to  definition and then Ctrl+M, Ctrl+M to toggle the current block to expanded or collapsed.

  9. Shift+ F12, Finds a reference to the selected item or the item under the cursor

  10. Ctrl-Shift-F12, Moves to the next task in the TaskList window

  • Digg
  • DZone
  • Yahoo Buzz
  • Delicious
  • Reddit
  • StumbleUpon
  • SmakNews
  • Jumptags
  • Ping
  • Share/Bookmark

IIS Search Engine Optimization (SEO) Toolkit

The IIS Search Engine Optimization (SEO) Toolkit is an IIS7 extension that helps identify search engine and user experience optimizations for Web sites. The following features are included:
Site Intelligence

  • Reporting and error identification for broken/invalid links, duplicate content, tag validation, etc.
  • Visibility into user routes, referring pages and other patterns
  • Drilldown into page resource usage and load time

Search Relevance

  • Best practice rules for optimizing URL structure for search engines
  • Extensibility model to enable integration for keyword acquisition
  • Automatic generation of search engine support files like sitemaps and robots.txt

Key Features including

  • Improve the volume and quality of traffic to your Web site from search engines
  • Control how search engines access and display Web content
  • Inform search engines about locations that are available for indexing
  • Site Analysis Features
  • Robots Exclusion Features
  • Sitemap and Sitemap Index Features

 

Instructions

You will need to run the installation package as an administrator. This can be accomplished by one of the following methods:

  • Logging in to your server as an administrator account and then double-clicking on the MSI file.
  • Logging on using an account with administrator privileges and opening a command-prompt by right-clicking the Command Prompt menu item that is located in the Accessories menu for Windows programs and selecting "Run as administrator", then typing one of the commands listed below:
    msiexec /I IISSEO_x86.msi
    msiexec /I IISSEO_x64.msi

It takes less than 5 minutes to download and run the SEO Toolkit Analyzer against your web-site.  You simply point the tool at the top-level URL of your web-site, and then it will automatically crawl your site like a search engine would – following each link, reviewing the HTML on each page, and generating a human friendly report of every SEO or content violation it finds on the site – along with suggestions on how to fix each of them.

If you haven’t downloaded the SEO Toolkit and used it to analyzer your web-site yet, then spend 10 minutes now and give it a try.  You’ll find it provides a really easy, automated way to quickly find and identify SEO issues you have on your web-site – along with suggestions on how to fix them.  Fixing them will increase the traffic and visitors to your web-site.

  • Digg
  • DZone
  • Yahoo Buzz
  • Delicious
  • Reddit
  • StumbleUpon
  • SmakNews
  • Jumptags
  • Ping
  • Share/Bookmark