I am still not completely sure what all of the pieces are in your implementation. So I wanted to propose my own solution that may help you. Also, here is a link to an article about creating User Controls in case you find it useful.
User Control
My Solution:
Add Web User Control to project named TinyMCE.
In the ASCX file place the following (You will need to change the reference location of tinyMCE to fit your setup):
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="TinyMCE.ascx.cs" Inherits="TinyMCE" %>
<script type="text/javascript" src="../tinymce/tinymce.min.js"></script>
<textarea id="HTMLText" runat="server" name="area" style="position: relative;"></textarea>
In the ASCX.cs File Place the following:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class TinyMCE : System.Web.UI.UserControl
{
public Unit Height { get; set; }
public Unit Width { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(Page, this.GetType(), "initScript", ConstructInitJavascript(), true);
}
private string ConstructInitJavascript()
{
StringBuilder sb = new StringBuilder();
sb.Append("$(document).ready(");
sb.Append("tinymce.init({ " +
"selector: \"textarea\"," +
"theme: \"modern\",");
if(Height != null)
{
sb.Append("height:\"" + Height.ToString() + "\"," );
}
if(Width != null)
{
sb.Append("width:\"" + Width.ToString() + "\"," );
}
sb.Append(
"plugins: [ " +
" \"advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker\","+
" \"searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking\","+
" \"save table contextmenu directionality emoticons template paste textcolor\""+
"],"+
"menubar: \"edit format insert table view tools\","+
"toolbar: \"undo redo | forecolor backcolor | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | preview \","+
"}));");
return sb.ToString();
}
public string GetContent()
{
return HTMLText.InnerText;
}
}
Some notes about this code: The public Unit Height and Width functions are what allow you to use the Height and Width properties on the user control declaration on the aspx page.
TinyMCE will adjust its width automatically to the element containing it. However, if its width and Height are specified it will honor them and not the element that contains it. The ConstructInitJavascript() function creates the tiny.init function with the width and height parameters that are set on the user control. This will allow you to specify the height and width of the control. If these are not specified tinymce will expand its width to the width of its containing element. The height does not seem to expand beyond a minimum setting.
The GetContent() method returns the HTML text from the tinyMCE editor.
To use the control on the aspx page register the user control:
<%@ Register src="TinyMCE.ascx" tagname="TinyMCE" tagprefix="uc1" %>
Then create a user control on the aspx page.
<uc1:TinyMCE ID="tiny" runat="server" Width="500" Height="700" />
I hope this helps, please let me know if you have any questions or need further assistance.