Hvorfor bruger du ikke en asp.net kontrol?
<asp:TextBox ID="TextBox1" TextMode="multiline" runat="server"></asp:TextBox> bliver til textarea og virker fint med tinyMCE.
Det havde ikke rigtig nogen effekt, men jeg har googlet og googlet igen, og fundet en ny stump kode til at indlæse tekst fra en fil på disken... og fandt noget der virkede... bortset fra at det er kun den sidste linje tekst i filen der bliver vist i editoren. Jeg kan også godt se at det er fordi at min textarea.Text bliver overskrevet hver gang while lykken kører, men hvordan får jeg den til at tilføje teksten til variablen i stedet for at overskrive den? ...
Det er koden i Page_Load jeg har opdateret med noget nyt kode.
Håber nogen kan give svaret :-)
På forhånd tusind tak.
Mvh Jacob
c# fil:
using System;
using System.IO;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
public partial class _Default : System.Web.UI.Page
{
// VARIABLER
string datashare = "\\\\192.168.250.48\\pages\\";
// VARIABLER SLUT
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Du redigere nu siden " + Session["Page"] + " under emnet " + Session["Subject"]);
if (!IsPostBack)
{
// Åbn .html fil fra datasharet...
string filetoopen = datashare + Session["Subject"] + "\\" + Session["Page"];
StreamReader re = File.OpenText(filetoopen);
string input = null;
while ((input = re.ReadLine()) != null)
{
textarea.Text = input;
}
re.Close();
}
}
protected void Gem_Click(object sender, EventArgs e)
{
string filetoedit = datashare + Session["Subject"] + "\\" + Session["Page"];
// create a writer and open the file
TextWriter tw = new StreamWriter(filetoedit);
// write a line of text to the file
tw.WriteLine(textarea.Text);
// close the stream
tw.Close();
}
}
asp fil:
<%@ Page Language="C#" ValidateRequest="false" AutoEventWireup="true" CodeFile="editor.aspx.cs" Inherits="_Default" %>
<%@ Register assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI" tagprefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>RichTextBox Demonstration</title>
<script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
// General options
mode : "textareas",
theme : "advanced",
plugins: "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
// save_enablewhendirty : true,
// save_onsavecallback : "MySave",
// Theme options
theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4: "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// Example content CSS (should be your site CSS)
content_css : "css/content.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<%--<textarea id="htmltxt" name="htmltxt" rows="15" cols="80" style="width: 80%" runat="server">
</textarea>--%>
<asp:TextBox ID="textarea" TextMode="multiline" runat="server"></asp:TextBox>
<br />
</div>
<p>
<asp:Button ID="Gem_Button" runat="server" onclick="Gem_Click" Text="Gem" />
</p>
</form>
</body>
</html>