嗨,我已将tinyMCE文本编辑器添加到我的项目中。但是现在我的表单不会提交,我也没有收到任何错误消息或任何东西。我在这里做错了什么?
我的 .cshtml 代码
@{
Layout = "~/Views/_Layout.cshtml"; //Got a link to the tinyMCE file
var con = DatabaseConnection.createConnection();
string subject = "";
string content = "";
string signed = "";
string message_error = "";
int subfolderTo = 0;
int id = 0;
bool error = false;
if(Request["btn"] == "Save entry")
{
subject = Request["subject"];
content = Request["content"];
signed = Request["signed"];
if(Request.QueryString["Chapter"] != null)
{
subfolderTo = Convert.ToInt32(Request.QueryString["Chapter"]);
}
if(subfolderTo == 0)
{
try
{
id = Subjects.Create(con, SessionHandler.WhoIsLoggedIn._id, subject, content, signed);
Response.Redirect("~/Pages/Chapters/Read.cshtml?Chapter=" + id);
}
catch
{
error = true;
message_error = "A monkey ran away with the text before we could save it, we are very sorry. Please try again.";
}
}
else
{
try
{
id = Subjects.Create(con, SessionHandler.WhoIsLoggedIn._id, subject, content, signed, subfolderTo);
Response.Redirect("~/Pages/Chapters/Read.cshtml?Chapter=" + id);
}
catch
{
error = true;
message_error = "A monkey ran away with the text before we could save it, we are very sorry. Please try again.";
}
}
}
}
@section head{
<script type="text/javascript">
tinymce.init({
selector: "textarea",
theme: "modern",
plugins: [
"advlist autolink lists link image charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars code fullscreen",
"insertdatetime media nonbreaking save table contextmenu directionality",
"emoticons template paste textcolor moxiemanager"
],
toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
toolbar2: "print preview media | forecolor backcolor emoticons",
image_advtab: true,
templates: [
{ title: 'Test template 1', content: 'Test 1' },
{ title: 'Test template 2', content: 'Test 2' }
]
});
</script>
}
<div>
<h1>
Write new entry
</h1>
<form action="" method="post">
<p class="Error_Message">@message_error</p>
<table>
<tr>
<td>
<p>
<input type="text" name="subject" placeholder="Subject" value="@subject" required="required"/>
</p>
</td>
</tr>
<tr>
<td>
<p>
<textarea name="content" placeholder="Content" required="required"></textarea> // used to be a <input type="text" ... /> before
</p>
</td>
</tr>
<tr>
<td>
<p>
<input type="text" name="signed" placeholder="In-time signed name" value="@signed" required="required" />
</p>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Save entry" name="btn" />
</td>
</tr>
</table>
</form>
</div>