I have 2 update panel in one update panel i have a datalist and in other update panel I have a textbox with tinymce editor.
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DataList ID="dlst1" runat="server" RepeatDirection="Horizontal" CellSpacing="5" CellPadding="7"
DataKeyField="Id" CaptionAlign="Left" OnItemCommand="dls1_ItemCommand"
OnItemDataBound="dlst1_ItemDataBound">
<ItemTemplate>
<asp:ImageButton ID="btnImg" OnClientClick="javascript:void(0);"
runat="server" ImageUrl='<%#"~/Controls/Images.ashx?FileName=" +DataBinder.Eval(Container.DataItem, "FilePath") %>'
CommandName="Select" OnCommand="Select_Command"
CommandArgument='<%# Eval("Id").ToString() ' />
</ItemTemplate>
</asp:DataList>
</ContentTemplate>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:TextBox ID="TextBox1" CssClass="tinyEditor" ClientIDMode="Static" runat="server" TextMode="MultiLine"></asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>
for making tinymce worked I am using
ScriptManager.RegisterClientScriptBlock(UpdatePanel2, this.GetType(), "init", "tinyMCE.execCommand('mceAddControl', false, '" + TextBox1.ClientID + "');", true);
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function () {
TinyMCEEditor();
});
$(function () {
TinyMCEEditor();
});
my TinyMCE Editor
function TinyMCEEditor() {
tinyMCE.init({
mode: "textareas",
theme: "advanced"
});
}
on page load.
I am giving the text for every image, for the previous image I am storing the textbox value in a view state, suppose I have 3 images for image 1 i have given the text abcd and selected image2, so image 1 text will store in the viewstate.
on Select_Command:
if (ViewState["txbtext"] != null)
txbtext= (Hashtable)ViewState["txbtext"];
int index1 = previouslySelectedIndex;
if (index1 != -1)
{
ImageButton imgbtn= (dlst1.Items[index1].FindControl("btnImg") as ImageButton);
if (imgbtn!= null)
{
string[] ImgStr = imgbtn.CommandArgument.ToString().Split(';');
Int32 selectedId = Convert.ToInt32(Str[0]);
if (txbtext!= null && txbtext.ContainsKey(selectedId))
txbtext[selectedId] = textbox.Text;
else
txbtext.Add(selectedId, textbox.Text);
}
}
ViewState["txbtext"] = txbtext (//this is the hashtable);
}
when I was not using update panel it was working fine, but as I am using update panel I am not able to store the textbox value in viewstate,
Please someone tell me how can I fix this issue, if possible give some exp. code.
Some one plz help me
I have added
for my TInyMCE Editor its working now…