Hiya all,
I have a page which loads the TinyMCE editor. On the postback I obviously want to fetch that data again but the value stays empty. Strangely enough, when I disable the "updatepanel" control I do get the value. Now, this leaves me puzzled.
Here's the code (c# from code behind) for the page that reads and writes the TinyMCE text:
1 private Question _question;
2
3 protected Question Question
4 {
5 get {
6 if(_question == null)
7 _question = GuiLayer.SelectQuestion(Convert.ToInt32(Request.QueryString["id"].ToString()));
8 return _question;
9 }
10 }
11
12 protected void Page_Load(object sender, EventArgs e)
13 {
14 if (!Page.IsPostBack)
15 {
16 txtTekst.Text = Server.HtmlDecode(Question.AnswerPrefab);
17 DataBind();
18 }
19 }
20
21 protected void btnsaveQuestion_Click(object sender, EventArgs e)
22 {
23 if (Page.IsValid)
24 {
25 ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "init", "InitTiny();", true);
26 Question.AnswerPrefab = Server.HtmlEncode(txtTekst.Text);
27 GuiLayer.UpdateQuestion(_question);
28 }
29 }
Here's the corresponding asp.net page:
1 <asp:Content ID="Content1" ContentPlaceHolderID="DefaultPlaceHolder" Runat="Server">
2 <script src="../../Scripts/tiny_mce/tiny_mce.js" type="text/javascript" language="javascript"></script>
3 <script type="text/javascript" language="javascript">
4 tinyMCE.init({
5 mode : "textareas",
6 encoding : "xml",
7 theme : "advanced",
8 theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,link,bullist,numlist,undo,redo,code",
9 theme_advanced_buttons2 : "",
10 theme_advanced_buttons3 : "",
11 theme_advanced_toolbar_location : "top",
12 theme_advanced_toolbar_align : "left",
13 theme_advanced_path_location : "bottom",
14 theme_advanced_resize_horizontal : false,
15 theme_advanced_resizing : true,
16 apply_source_formatting : true,
17 extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]"
18 });
19
20 function InitTiny()
21 {tinyMCE.execCommand('mceAddControl', false, '<%# txtTekst.ClientID %>');}
22 </script>
23 <h3>ManageQuestion</h3>
24 <p><asp:textbox runat="server" id="txtTekst" width="100%" textmode="multiLine" columns="80" rows="15" /></p>
25 <br />
26 <asp:button runat="server" id="btnSave" text="Save" onclick="btnsaveQuestion_Click" />
27
28 <asp:button runat="server" id="btnBack" text="Back" postbackurl="~/Pages/Admin/ManageSurvey.aspx" />
29
30 </asp:Content>
any help would be appreciated (obviously
).
Cheers, Nathan