文章标题被变更后如何进行同步
内部网站,资讯文员收集各部门发布的文章,然后做电子报。有这样一种情况出现,电子报发出之后,原文章作者有可能对标题作变更,这样会从电子报看到的标题与点击链接看到的标题不一样。为了解决这个问题,得想办法实现文章标题同步。
以前是在做文章引用时,需要做两个复制步骤,复制标题和URL。是否可以只传入URL取得这个Page的标题呢?答案是肯定的。Insus.NET把这个功能整合至一个类别。可以从这里下载:http://www.cnblogs.com/insus/articles/2023258.html 接下来,我会修改原有网页的功能。创建一个User Control:
xxx.ascx:
<asp:HyperLink ID="HyperLink1" runat="server" Target="_blank"></asp:HyperLink>
xxx.ascx.cs:
View Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Insus.NET;
public partial class CopiedArticle : System.Web.UI.UserControl
{
private string _Url;
public string Url
{
set
{
_Url = value;
}
}
InsusMetaUtility objInsusMetaUtility = new InsusMetaUtility();
InsusJsUtility objInsusJsUtility = new InsusJsUtility();
protected void Page_Load(object sender, EventArgs e)
{
try
{
objInsusMetaUtility.GetWebPageTitle(_Url);
this.HyperLink1.NavigateUrl = _Url;
this.HyperLink1.Text = "《[转载] " + objInsusMetaUtility.GetWebPageTitle(_Url) + "》";
}
catch (Exception ex)
{
objInsusJsUtility.JsAlert(ex.Message);
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Insus.NET;
public partial class CopiedArticle : System.Web.UI.UserControl
{
private string _Url;
public string Url
{
set
{
_Url = value;
}
}
InsusMetaUtility objInsusMetaUtility = new InsusMetaUtility();
InsusJsUtility objInsusJsUtility = new InsusJsUtility();
protected void Page_Load(object sender, EventArgs e)
{
try
{
objInsusMetaUtility.GetWebPageTitle(_Url);
this.HyperLink1.NavigateUrl = _Url;
this.HyperLink1.Text = "《[转载] " + objInsusMetaUtility.GetWebPageTitle(_Url) + "》";
}
catch (Exception ex)
{
objInsusJsUtility.JsAlert(ex.Message);
}
}
}
保留一个TextBox,让用户输入引用或转载的URL和一个Button。用户帖完Url之后,点击这个铵钮,会动态加载上面的User Control用户控件。
执行结果,如: