Hello,
So far so good I got the FCKEditor control displaying all the nice buttons.
I can enter text and use my submit button. But nothing happens.
I wonder if I have made a mistake when it comes to binding the textbox (that should write HTML to the database).
how does my html code get to the controler AddBLog action (having the HTML from the FCKEditor as a parameter).
<FCKeditorV2:FCKeditor ID="FCKeditor" runat="server"></FCKeditorV2:FCKeditor>
<input type="submit" value="Add Blog" />
--------------------vb controller---------------------------------------
<AcceptVerbs(HttpVerbs.Post)> _
Public Function AddBlog(ByVal form As FormCollection)
Dim blogToAdd As New AHN.ahn_blogs
' Deserialize (Include white list!)
TryUpdateModel(blogToAdd, New String() {"Title", "Director"}, form.ToValueProvider())
' Validate
If String.IsNullOrEmpty(blogToAdd.BLOGNAME) Then
ModelState.AddModelError("Title", "Title is required!")
End If
If String.IsNullOrEmpty(blogToAdd.BLOG) Then
ModelState.AddModelError("Director", "Director is required!")
End If
' If valid, save movie to database
If (ModelState.IsValid) Then
_db.AddToahn_blogs(blogToAdd)
_db.SaveChanges()
Return RedirectToAction("Index")
End If
' Otherwise, reshow form
Return View(blogToAdd)
End Function
Sun, 02/07/2010 - 13:55
#1
Re: .NET From FCKEditor TextBox to database
I was using CKEditor on ASP.net with MVC for a forum like app we were working on and what i ended up doing was did the following:
(also want to add i'm not a microsoft developer just been working in it recently so i hope this helps)
Re: .NET From FCKEditor TextBox to database
I dont get it, where is the submit button, where is the controller method that does the data writing (how does it get whats in the fckeditor)?
Re: .NET From FCKEditor TextBox to database
but even this way the submitting does not hit the controller:
<% using (Html.BeginForm()) {%>
<FCKeditorV2:FCKeditor ID="FCKeditor" runat="server"></FCKeditorV2:FCKeditor>
<input type="submit" value="Create" />
<% } %>
<AcceptVerbs(HttpVerbs.Post)> _
Public Function AddBlog(ByVal form As FormCollection)
Dim blogToAdd As New AHN.ahn_blogs
' Deserialize (Include white list!)
TryUpdateModel(blogToAdd, New String() {"Title", "Director"}, form.ToValueProvider())
' Validate
If String.IsNullOrEmpty(blogToAdd.BLOGNAME) Then
ModelState.AddModelError("Title", "Title is required!")
End If
If String.IsNullOrEmpty(blogToAdd.BLOG) Then
ModelState.AddModelError("Director", "Director is required!")
End If
' If valid, save movie to database
If (ModelState.IsValid) Then
_db.AddToahn_blogs(blogToAdd)
_db.SaveChanges()
Return RedirectToAction("Index")
End If
' Otherwise, reshow form
Return View(blogToAdd)
End Function