Hi,
I using a CKEditor plugin on my project ASP.NET C#.
With CKEditor it is possible to modify the row of the GridView by also inserting images using copy/paste.
This images copy/paste working correctly but on the text editor, but when the edit of row on the GridView is closed on the browser I have this return
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXgAAAD6CAYAAACrklzBAAAgAElEQVR4AeydB3gUR7bvR8J77/Pd3fve7t71Zq
I have tried without success
public static string SpliceText(string text, int lineLength)
{
var charCount = 0;
var lines = text.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries)
.GroupBy(w => (charCount += w.Length + 1) / lineLength)
.Select(g => string.Join(" ", g));
return String.Join("<br />", lines.ToArray());
}
protected void gvProducts_RowUpdating(Object sender, GridViewUpdateEventArgs e)
{
int ID = Convert.ToInt32(gvProducts.DataKeys[e.RowIndex].Value);
GridViewRow row = gvProducts.Rows[e.RowIndex];
TextBox txtpara = (TextBox)row.FindControl("txsezi");
string newText = txtpara.ToString().Replace("'", "`");
using (MySqlConnection myConnectionString =
new MySqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString))
{
using (MySqlCommand cmd =
new MySqlCommand("SP", myConnectionString))
{
cmd.Connection.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("tpara", newText.ToString());
cmd.Parameters.AddWithValue("tid", ID.ToString());
cmd.ExecuteNonQuery();
cmd.Connection.Close();
}
}
gvProducts.EditIndex = -1;
BindData();
}
<asp:TemplateField HeaderText="Text"
ItemStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label ID="lbsezi" runat="server"
Text='<%# HttpUtility.HtmlDecode(Mp2smal.SpliceText(Eval("contents").ToString(),150)) %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txsezi"
runat="server"
TextMode="MultiLine"
Text='<%# HttpUtility.HtmlDecode(Eval("contents").ToString()) %>'
CssClass="ckeditor"
CausesValidation="true"
ValidationGroup="ValidationSummary1"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfsezi" runat="Server"
ControlToValidate="txsezi"
SetFocusOnError="true" ErrorMessage="Required" Text=""
Display="None" ValidationGroup="ValidationSummary1"></asp:RequiredFieldValidator>
</EditItemTemplate>
</asp:TemplateField>
On the database it's stored this string
<p><span style="text-align:">Text row</span></p><p> </p><p><img alt="" src="data:image/png;base64,iVBORw...
Any help would greatly appreciate.
Thank you.