用于显示内容的修订或差异的 ASP.NET WebControl

标签 asp.net diff web-controls

我想显示相同内容的版本之间的差异。最初我推出了自己的 WebControl,但是我想出的差分算法有点幼稚。

有人知道互联网上可能有用的 .Net 代码或 WebControl 吗? stackoverflow 使用的实现正是我正在寻找的东西,例如:

alt text

更新:2008 年 12 月 12 日 我已将 jsdiff 实现包装到一个独立的 Web 控件程序集中,并将其上传到 MSDN 代码库 Text differencing and syntax highlighting ASP.Net WebControls .

更新:2008 年 11 月 12 日 遇到以下javascript differencing library 。将尝试将其包装在自定义 WebControl 中。输出看起来与 stackoverflow 使用的类似:

alt text

最佳答案

我使用你提到的js库。

将 .js 文件包含在脚本标记内,将名为 asp:Literal 的内容添加到页面

<asp:Literal ID="litCompare" runat="server">
</asp:Literal>

并添加到代码隐藏:

litComparison.Text = "<pre id=\"lbDiffPre\" class=\"code\"> </pre>";
ClientScript.RegisterStartupScript(GetType(), "calccompare",
    @"document.getElementById('lbDiffPre').innerHTML = 
    diffString(document.getElementById('" + edit1.ClientID + "').value, 
        document.getElementById('" + edit2.ClientID + "').value).
        replace(/\r\n/g, '<br>';", true);

在我的例子中,我有 2 个控件也显示原始值,您可能希望将字符串字面地包含在 diffString() 函数中。额外的replace()将\r\n换行符转换为HTML换行符。

关于用于显示内容的修订或差异的 ASP.NET WebControl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/359214/

相关文章:

asp.net - 如何在 Visual Studio 2012 中的空 Web 应用程序项目中添加带有 Razor 语法的 Web Pages 2?

c# - 存储过程 - INSERT 查询不起作用

bash - 如何使用shell脚本比较两个不同目录中的同名文件

java - 图像的差异/补丁

c# - 自定义 ASP.NET Web 控件 TextBox

ruby-on-rails - 有没有更简单的方法在 Ruby 中构建 HTML?

c# - 文本框输入从右到左,左侧为负号 "-"

.net - 无法加载文件或程序集 '' 或其依赖项之一。 API调用异常退出

regex - 忽略 diff 命令中带有反斜杠的模式

c++ - 我怎么能只允许 flash activeX 而其他人不允许在我的 webcontrol 中使用 IWebBrowser2?