【问题标题】:How to remove a tab attribute in ASP .NET AJAX Toolkit using Regular Expression如何使用正则表达式删除 ASP .NET AJAX 工具包中的选项卡属性
【发布时间】:2009-09-12 05:45:37
【问题描述】:

我已尝试删除由 AJAX 控件工具包生成的以下标记。 场景是我们的 GUI 团队使用 AJAX 控件工具包来制作 GUI,但我需要使用 MultiView 将它们移动到普通的 ASP .NET 视图标签。

我想删除所有的 __designer: 属性

这里是代码

<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" />

我尝试在 Visual Studio 中使用正则表达式查找替换:

查找:

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

用空白替换

任何正则表达式专家可以帮忙吗?

【问题讨论】:

    标签: asp.net regex visual-studio-2008 asp.net-ajax tabcontrol


    【解决方案1】:

    如果你想摆脱 __designer:mapid="22"

    使用这个正则表达式

    【讨论】:

      【解决方案2】:
      /*
       * 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);
              }
          }
      }
      

      【讨论】:

      • 该程序不需要,原始海报(OP)正在使用VS Find命令删除这些属性。 @"__designer:wfdid=""w\d+""" 可以。一个不错的做法是在属性后删除一个额外的空格,以避免有两个空格并增加整洁度。
      • 我明白了。但我刚刚安装了 Visual Studio 6.0。 ;P
      【解决方案3】:

      从“查找选项”使用通配符搜索:

      __designer:wfdid="*"

      找到所有这些并替换为空。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-12-02
        • 2020-12-04
        • 2011-09-18
        • 2021-06-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多