View Full Version : سوال: مشکل در کنترل kendo ui editor
kavayo
دوشنبه 11 فروردین 1393, 11:15 صبح
من زمانی که در ادیتور kendo متنی مینویسم و ان را در دیتابیس دخیره میکنم اطلاعات به درستی و بدون تگ های html ذخیره میشود ولی اگر همین متن را در ادیتور به صورت راست چین در بیاورم و ذخیره کنم تگ های html مانند تگ div بدان اضافه میشود و ویژگی Encode(false) را نیز بدان اضافه میکنم اما تاثیری ندارد حال چگونه میتوانم این مشکل را حل کنم؟
مهدی کرامتی
دوشنبه 11 فروردین 1393, 12:09 عصر
وقتی شما متن را فرمتی مانند راست چین می کند برای اعمال فرمت فوق Kendo Editor یک تگ شامل Span یا Div به متن انتخاب شده اضافه می کند و استایل مورد نظر را به آن تگ اضافه می کند. شما با کدام قسمتش مشکل دارید؟
kavayo
چهارشنبه 13 فروردین 1393, 14:47 عصر
من میخوام که متن من بدون هیچ تگ html ای ذخیره شود و یا اگر با این تگ ها دخیره شد در نمایش به کاربر متن بدون تگ های html نمایش داده شود
مهدی کرامتی
جمعه 15 فروردین 1393, 17:08 عصر
این یک کلاس آماده است برای این کار:
using System;
using System.Text.RegularExpressions;
/// <summary>
/// Methods to remove HTML from strings.
/// </summary>
public static class HtmlRemoval
{
/// <summary>
/// Remove HTML from string with Regex.
/// </summary>
public static string StripTagsRegex(string source)
{
return Regex.Replace(source, "<.*?>", string.Empty);
}
/// <summary>
/// Compiled regular expression for performance.
/// </summary>
static Regex _htmlRegex = new Regex("<.*?>", RegexOptions.Compiled);
/// <summary>
/// Remove HTML from string with compiled Regex.
/// </summary>
public static string StripTagsRegexCompiled(string source)
{
return _htmlRegex.Replace(source, string.Empty);
}
/// <summary>
/// Remove HTML tags from string using char array.
/// </summary>
public static string StripTagsCharArray(string source)
{
char[] array = new char[source.Length];
int arrayIndex = 0;
bool inside = false;
for (int i = 0; i < source.Length; i++)
{
char let = source[i];
if (let == '<')
{
inside = true;
continue;
}
if (let == '>')
{
inside = false;
continue;
}
if (!inside)
{
array[arrayIndex] = let;
arrayIndex++;
}
}
return new string(array, 0, arrayIndex);
}
}
مثالی از نحوه استفاده:
const string html = "<p>There was a <b>.NET</b> programmer " + "and he stripped the <i>HTML</i> tags.</p>"; Console.WriteLine(HtmlRemoval.StripTagsRegex(html) ); Console.WriteLine(HtmlRemoval.StripTagsRegexCompil ed(html)); Console.WriteLine(HtmlRemoval.StripTagsCharArray(h tml));
مهدی کرامتی
جمعه 15 فروردین 1393, 17:09 عصر
این یک کلاس آماده است برای این کار:
using System;
using System.Text.RegularExpressions;
/// <summary>
/// Methods to remove HTML from strings.
/// </summary>
public static class HtmlRemoval
{
/// <summary>
/// Remove HTML from string with Regex.
/// </summary>
public static string StripTagsRegex(string source)
{
return Regex.Replace(source, "<.*?>", string.Empty);
}
/// <summary>
/// Compiled regular expression for performance.
/// </summary>
static Regex _htmlRegex = new Regex("<.*?>", RegexOptions.Compiled);
/// <summary>
/// Remove HTML from string with compiled Regex.
/// </summary>
public static string StripTagsRegexCompiled(string source)
{
return _htmlRegex.Replace(source, string.Empty);
}
/// <summary>
/// Remove HTML tags from string using char array.
/// </summary>
public static string StripTagsCharArray(string source)
{
char[] array = new char[source.Length];
int arrayIndex = 0;
bool inside = false;
for (int i = 0; i < source.Length; i++)
{
char let = source[i];
if (let == '<')
{
inside = true;
continue;
}
if (let == '>')
{
inside = false;
continue;
}
if (!inside)
{
array[arrayIndex] = let;
arrayIndex++;
}
}
return new string(array, 0, arrayIndex);
}
}
مثالی از نحوه استفاده:
const string html = "<p>There was a <b>.NET</b> programmer " +
"and he stripped the <i>HTML</i> tags.</p>";
Console.WriteLine(HtmlRemoval.StripTagsRegex(html) );
Console.WriteLine(HtmlRemoval.StripTagsRegexCompil ed(html));
Console.WriteLine(HtmlRemoval.StripTagsCharArray(h tml));
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.