站内搜索
广告
runat=server
作者:    来源:    点击:    日期:2007-7-4 0:52:56   
背景:
当我们在窗体上添加web control例如label时,vs.net会自动添加runat=server把它当成服务器控件,但是当我们添加自定义的控件时,我们就无法自动得到runat=server我们必须每个空间都重复添加runat=server。
我们现在要做的就是做一个宏在vs.net中,它可以自动添加runat=server在我们指定的控件上,现在已经存在的runat=server他会忽略不计,不会重复添加。
'This macro checks the specified elements if they have runat=server in
'them and if not then automatically adds runat=server in them
Sub AddRunAtServer()
      'Create an Undo context object so all the changes can be
      'undone by CTRL+Z
      Dim oUnDo As UndoContext = DTE.UndoContext
      oUnDo.Open("Comment Line")         
       
      'Supress the User Interface. This will make it run faster
      'and make all the changes appear once
      DTE.SuppressUI = True
       
      Try
      'Make a call to UpdateDocument()
            UpdateDocument("<asp:")
            UpdateDocument("<form")
            UpdateDocument("<script")
            UpdateDocument("<body")
           
            'Finally Close the undo
            oUnDo.Close()
      Catch oException As system.Exception
            Dim lcErrMsg As String
            lcErrMsg = "An error occured while running this program." _
                              & " Please make sure that you are specifying the" _
                              & " correct parameters."
首页 上一页 [1] [2] [3] [4]  下一页 尾页 
runat=server 评论