views:

457

answers:

2

I have tried to remove the following tag generated by the AJAX Control toolkit. The scenario is our GUI team used the AJAX control toolkit to make the GUI but I need to move them to normal ASP .NET view tag using MultiView.

I want to remove all the __designer: attributes

Here is the code

<asp:TextBox ID="a" runat="server" __designer:wfdid="w540" />
<asp:DropdownList ID="a" runat="server" __designer:wfdid="w541" />
.....
<asp:DropdownList ID="a" runat="server" __designer:wfdid="w786" />

I tried to use the regular expression find replace in Visual Studio using:

Find:

:__designer\:wfdid="w{([0-9]+)}"

Replace with empty space

Can any regular expression expert help?

+2  A: 
/*
 * Created by SharpDevelop.
 * User: box
 * Date: 2009-9-13
 * Time: 8:13
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Text.RegularExpressions;

namespace t1
{
    class Sample
    {
     public static void Main()
     {
      // Create a regular expression that matches a series of one
      // or more white spaces.
      string pattern = @"__designer:wfdid=""w\d+""";
      Regex rgx = new Regex(pattern);

      // Declare a string consisting of text and white spaces.
      string aspCode = @"<asp:TextBox ID=""a"" runat=""server"" __designer:wfdid=""w540"" />";

      // Replace runs of white space in the input string with a
      // comma and a blank.
      string outputStr = rgx.Replace(aspCode, ", ");

      // Display the resulting string.
      Console.WriteLine("Pattern:       \"{0}\"", pattern);
      Console.WriteLine("Input string:  \"{0}\"", aspCode);
      Console.WriteLine("Output string: \"{0}\"", outputStr);
     }
    }
}
boxoft
The program isn't needed, the Original Poster (OP) is using the the VS Find command to remove these attributes. @"__designer:wfdid=""w\d+""" will do. A nice touch is to remove an extra space after the attribute, to avoid having two spaces and increase neatness.
Kobi
I see. But I have just Visual Studio 6.0 installed. ;P
boxoft
+2  A: 

If you want to get rid of __designer:mapid="22"

use this regex

<__designer\:mapid=:q

DonP