如何令VS.NET 2002不要再改变我的HTML源代码视图了!!!

sungoodnews 2003-06-12 05:06:47
VS.NET 2002非常令我头疼!一转换设计视图和代码视图,VS.NET就会加入很多垃圾<font name="宋体"></font>还有就是把全角的空格改称半角的!如何令VS.NET 2002不要再改变我的HTML源代码视图了!!!
...全文
24 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
lostinetdotcom 2003-06-19
  • 打赏
  • 举报
回复
警告:要事先进行备份~
lostinetdotcom 2003-06-19
  • 打赏
  • 举报
回复
按Alt+F8,新建一个Module,选编辑。
复制下面代码。
保存关闭宏IDE,按Alt+F8,运行“我的工具"-"去除所有Aspx垃圾"

Imports EnvDTE
Imports System
Imports System.Collections
Imports System.Diagnostics
Imports System.IO
Imports System.Text
Imports System.Text.RegularExpressions


Public Module 我的工具

'copy frum example
Function GetOutputWindowPane(ByVal Name As String, Optional ByVal show As Boolean = True) As OutputWindowPane
Dim win As Window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
If show Then win.Visible = True
Dim ow As OutputWindow = win.Object
Dim owpane As OutputWindowPane
Try
owpane = ow.OutputWindowPanes.Item(Name)
Catch e As System.Exception
owpane = ow.OutputWindowPanes.Add(Name)
End Try
owpane.Activate()
Return owpane
End Function

Sub 清除内存()
Dim i As Int32
For i = 0 To 10
GC.Collect(10)
Next
End Sub

Public Sub 去除所有Aspx垃圾()

Try
DeleteAspxTagsInternal()
Catch x As Exception
MsgBox(x.ToString())
Throw
End Try

End Sub

Private Sub DeleteAspxTagsInternal()

Dim Output As OutputWindowPane = GetOutputWindowPane("我的工具")

Output.Clear()

Dim i As Int32
For i = 1 To DTE.Solution.Projects.Count
Dim proj As Project = DTE.Solution.Projects.Item(i)
If proj.Properties.Item("ProjectType").Value = 1 Then

Output.OutputString("正在读取项目配置 - " & proj.FullName)
Output.OutputString(vbCrLf)

Dim al As ArrayList = GetFileItems(proj, ".aspx")
Dim projitem As ProjectItem

Output.OutputString("开始处理文件")
Output.OutputString(vbCrLf)

For Each projitem In al

Dim filename As String = projitem.Properties.Item("FullPath").Value

Dim count As Int32

count = ReplaceFile(filename)

Output.OutputString(filename & " OK - " & count)
Output.OutputString(vbCrLf)

Next

Output.OutputString(al.Count & " Files OK")
Output.OutputString(vbCrLf)
End If
Next
End Sub

Dim regexstrs As String() = New String() {"<FONT[^>]*>", "", "</FONT>", "", "<!DOCTYPE[^>]*>", "", "<META[^>]*>", "", "(\r\n)[ \t]*\r\n", "$1"}

'替换文件内容
Function ReplaceFile(ByVal filename As String) As Int32

Dim regcount As Int32 = regexstrs.Length / 2
Dim regexs As Regex() = New Regex(regcount) {}
Dim i As Int32
For i = 0 To regcount - 1
regexs(i) = New Regex(regexstrs(i * 2), RegexOptions.ECMAScript Or RegexOptions.IgnoreCase Or RegexOptions.Compiled)
Next


Dim s As String

Dim sr As New StreamReader(filename, Encoding.GetEncoding("gb2312"))
s = sr.ReadToEnd()
sr.Close()

Dim count As Int32 = 0
For i = 0 To regcount - 1
count = count + regexs(i).Matches(s).Count()
Next

If count = 0 Then
Return 0
End If

Dim fs As New FileStream(filename, FileMode.Truncate, FileAccess.Write)

For i = 0 To regcount - 1
While regexs(i).IsMatch(s)
s = regexs(i).Replace(s, regexstrs(i * 2 + 1))
End While
Next

Dim sw As New StreamWriter(fs, Encoding.GetEncoding("gb2312"))
sw.Write(s)

sw.Flush()
fs.Close()

Return count

End Function

'取得包含文件ProjectItem的ArrayList
Function GetFileItems(ByVal proj As Project, ByVal ext As String) As ArrayList
Dim al As New ArrayList
AppendToArrayList(al, proj.ProjectItems, ext)
Return al
End Function

'递归把符合ext的文件的ProjectItem添加到al中
Private Sub AppendToArrayList(ByVal al As ArrayList, ByVal items As ProjectItems, ByVal ext As String)
Dim item As ProjectItem
For Each item In items
If item.Kind = Constants.vsProjectItemKindPhysicalFile And item.Name.ToLower().EndsWith(ext) Then
DTE.StatusBar.Text = item.Properties.Item("FullPath").Value
al.Add(item)
End If
AppendToArrayList(al, item.ProjectItems, ext)
Next
End Sub

End Module

kld3000 2003-06-19
  • 打赏
  • 举报
回复
用DW做HTML吧
然后把事件写进cs文件

gj2008 2003-06-18
  • 打赏
  • 举报
回复
我也遇到这个问题,我是这样处理的
一般不用VS设计HTML
实在不行,最后用替换将以上字符替换掉!
sungoodnews 2003-06-18
  • 打赏
  • 举报
回复
鄙视IDE
ArLi2003 2003-06-13
  • 打赏
  • 举报
回复
在这方面IDE 也只能这样,不改代码那更多的用户是靠IDE写HTML的用户如何是好?毕竟你是小部分。。基本上大部分会的人都会面临这样的问题

你只要不改动界面上的东西,只要去挂钩属性表中相应事件问题就不大
sungoodnews 2003-06-13
  • 打赏
  • 举报
回复
鄙视IDE
xiongliang2003 2003-06-12
  • 打赏
  • 举报
回复
呵呵呵 ,这个问题比较老火,不过 你说的“一转换设计视图和代码视图,VS.NET就会加……”
我的转换设计视图和代码视图是 不会产生的, 应该是你又在界面上拖动了什么才会产生。

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧