Asp.net 阅读更多问题

Asp.net 阅读更多问题,asp.net,Asp.net,我确实读了更多的函数,但它不能正常工作。我的意思是我可以拆分我的测试帖子,我可以用substring函数剪切我的字符串。我是用)我解决不了这个问题。如果我用的是正则表达式,它只会让它们都像文本一样,而且我的文章中没有html标记,这是不好的。我的意思是,如果在我的帖子中有一些链接或表格,它们将不会显示。它们只是文本 这是我的小代码 #region ReadMore string strContent = drvRow["cont"].ToString(); //strContent = Se

我确实读了更多的函数,但它不能正常工作。我的意思是我可以拆分我的测试帖子,我可以用substring函数剪切我的字符串。我是用<<来做这件事的--kamore-->关键字

但是在我用substring剪切这个之后,做innerhtml,如果在索引之前有一些html标记,css会变得疯狂。(!--kamore-->)我解决不了这个问题。如果我用的是正则表达式,它只会让它们都像文本一样,而且我的文章中没有html标记,这是不好的。我的意思是,如果在我的帖子中有一些链接或表格,它们将不会显示。它们只是文本

这是我的小代码

#region ReadMore

string strContent = drvRow["cont"].ToString();

//strContent = Server.HtmlDecode(strContent);
//strContent = Regex.Replace(strContent, @"</?\w+((\s+\w+(\s*=\s*(?:"".*?""|'.*?'|[^'"">\s]+))?)+\s*|\s*)/?>", string.Empty);

// More extension by kad1r
int kaMoreIndex;
kaMoreIndex = strContent.IndexOf("<!--kamore-->");
if (kaMoreIndex > 0)
{
    if (strContent.Length >= kaMoreIndex)
    {
        aReadMore.Visible = true;
        article.InnerHtml = strContent.Substring(0, kaMoreIndex);
        // if this ends like this there is a problem
        // < p>< !--kamore--> or < div>< !--kamore-->
        // because there is no end of this tag!
    }
    else
    {
        article.InnerHtml = strContent;
    }
}
else
{
    article.InnerHtml = strContent;
}

#endregion
#地区详情
字符串strContent=drvRow[“cont”].ToString();
//strContent=Server.HtmlDecode(strContent);

//strContent=Regex.Replace(strContent,@“我修复了它。我找到了这段代码,在找到后,我将其添加到了我的字符串中。现在一切正常。

您需要确保插入的标记与容器“兼容”。您决定如何执行该操作取决于您。例如,如果存在错误会发生什么?是的,您是对的。一个或多个html标记不会以这种方式关闭。您知道如何替换未关闭的html标记吗?regex或其他什么?