开发者

read more problem

开发者 https://www.devze.com 2023-01-19 20:34 出处:网络
I did read more function but it\'s not working correctly. I mean I can split my test post and I can cut my string with substring function. And I did this using < !--kamore--> keyword.

I did read more function but it's not working correctly. I mean I can split my test post and I can cut my string with substring function. And I did this using < !--kamore--> keyword.

But after I cut this with substring and do innerhtml and if there is some html tag before the index the css is going crazy. (< p>< !--kamore-->) I can't solve this. If I'm using regex it just make all of them like text and there is no html tags in my post and it's n开发者_高级运维ot good. I mean if there is some links or table in my post they will not showing. They are just text.

Here is my little code.

#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


I fix it. I found this code and after finding I added to my string. Now everything works fine. http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/0f06a2e9-ab09-4692-890e-91a6974725c0

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号