Her er et sampel af hele min kode. Bemærk at det javascript som er defineret hendviser til et textredigerings script som kan hentes på
http://tinymce.moxiecode.com/ <%@ Page Language="C#" ContentType="text/html" ValidateRequest="false" debug="true" %>
<%@ import namespace="System.IO"%>
<%@ import namespace="System.Data"%>
<%@ import namespace="System.Data.OleDb"%>
<script runat="server">
void Page_Load(Object Sender, EventArgs E) {
if (!IsPostBack){
OleDbConnection OurConnection;
OurConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("../db/content.mdb")+";");
OurConnection.Open();
OleDbCommand OurCommand;
OleDbDataReader OurDataReader;
OurCommand = new OleDbCommand("SELECT * FROM online",OurConnection);
OurDataReader = OurCommand.ExecuteReader();
OurDataReader.Read();
elm1.Text = OurDataReader["tekst"].ToString();
OurConnection.Close();
OurDataReader.Close();
}
}
public void opdater(Object sender, System.Web.UI.WebControls.CommandEventArgs e) {
OleDbConnection OurConnection;
OleDbCommand OurCommand;
String id = e.CommandArgument.ToString();
OurConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("../db/content.mdb")+";");
OurCommand = new OleDbCommand("UPDATE online SET tekst = @tekst WHERE id = id", OurConnection);
OurCommand.Parameters.Add("@tekst", OleDbType.VarChar, 20000).Value = elm1.Text;
OurCommand.Parameters.Add("@id", OleDbType.Integer).Value = 1; OurConnection.Open();
OurCommand.ExecuteNonQuery();
OurConnection.Close();
}
</script>
<html>
<head>
<title>Online CV</title>
<!-- TinyMCE -->
<script language="javascript" type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins : "style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,flash,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable",
theme_advanced_buttons1_add_before : "save,newdocument,separator",
theme_advanced_buttons1_add : "fontselect,fontsizeselect",
theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,separator,forecolor,backcolor",
theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator",
theme_advanced_buttons3_add_before : "tablecontrols,separator",
theme_advanced_buttons3_add : "emotions,iespell,flash,advhr,separator,print,separator,ltr,rtl,separator,fullscreen",
theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_path_location : "bottom",
content_css : "example_full.css",
plugin_insertdate_dateFormat : "%Y-%m-%d",
plugin_insertdate_timeFormat : "%H:%M:%S",
extended_valid_elements : "hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
external_link_list_url : "example_link_list.js",
external_image_list_url : "example_image_list.js",
flash_external_list_url : "example_flash_list.js",
file_browser_callback : "fileBrowserCallBack",
theme_advanced_resize_horizontal : false,
theme_advanced_resizing : true
});
function fileBrowserCallBack(field_name, url, type, win) {
// This is where you insert your custom filebrowser logic
alert("Example of filebrowser callback: field_name: " + field_name + ", url: " + url + ", type: " + type);
// Insert new URL, this would normaly be done in a popup
//win.document.forms[0].elements[field_name].value = "someurl.htm";
}
</script>
<!-- /TinyMCE -->
</head>
<body>
<form enctype="multipart/form-data" runat="server">
<table width="980" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="655"><asp:TextBox ID="elm1" TextMode="MultiLine" Width="400" Height="200" runat="server" /></td>
</tr>
<tr>
<td width="319""><asp:Button ID="rediger" style="background-color: #FFFFFF;border: 0px; text-decoration:underline" oncommand="opdater" Text="Opdater" runat="server" /></td>
</tr>
</table>
</form>
</body>
</html>