Question

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?

Was it helpful?

Solution

/*
 * 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);
        }
    }
}

OTHER TIPS

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

use this regex

<__designer:mapid=:q

from 'Find option' use Wildcards search :

__designer:wfdid="*"

find All of them and replace with empty.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top