473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Rich Text Editing, designMode, and Javascript (again)

I've found several posts discussing this, but I'm still stumped.

Pasted below is the HTML for a simple aspx file I created in a 1.1
environment. My goal is to give my users a rich text editor, and then
have the HTML submitted to the code behind as a form variable so I can
manipulate it any way I want. The page renders correctly, and the user
can type in the iFrame. And I've determined (via calls to alert())
that setBody() is being called and values are set correctly. But on
the back end I'm consistantly not getting any of the text in the
iframe. I've even written versions that were Netscape friendly, and
had the exact same results.

Any ideas? If I could get this to work it would solve a big problem
for me.

iframeTest.aspx:

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="iFrameTest.aspx.vb" Inherits="iFrameTest"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>iFrameTest</title>

<script>
function setEditor(md) {
// document.editorFrame.document.body.innerHTML = "<b>This is a
test</breally.";
document.editorFrame.document.designMode=md;
}

function setBody() {

var msgTxt, bdy;

msgTxt = document.editorFrame.document.body.innerHTML;
bdy = document.getElementById("messageBody");
bdy.Value = msgTxt;

return true;
}

</script>

</head>
<body onLoad="setEditor('On');">

<form id="Form1" method="post" onsubmit="return setBody();">
<iframe class="bodyBox" name="editorFrame" id="editorFrame">
</iframe>
<input type="hidden" name="messageBody"/>
<input type="submit">
</form>

</body>
</html>

iframeTest.aspx.vb:

Public Class iFrameTest
Inherits System.Web.UI.Page

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Not Request.Form("messageBody") Is Nothing Then

If Request.Form("messageBody").Length 0 Then
Response.Write("got a value!")
Else
Response.Write("still nothing")
End If

End If

End Sub

End Class

Oct 3 '06 #1
3 1903
Try adding: runat="server" to your form.

"Erik" <ea****@sheppardmullin.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
I've found several posts discussing this, but I'm still stumped.

Pasted below is the HTML for a simple aspx file I created in a 1.1
environment. My goal is to give my users a rich text editor, and then
have the HTML submitted to the code behind as a form variable so I can
manipulate it any way I want. The page renders correctly, and the user
can type in the iFrame. And I've determined (via calls to alert())
that setBody() is being called and values are set correctly. But on
the back end I'm consistantly not getting any of the text in the
iframe. I've even written versions that were Netscape friendly, and
had the exact same results.

Any ideas? If I could get this to work it would solve a big problem
for me.

iframeTest.aspx:

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="iFrameTest.aspx.vb" Inherits="iFrameTest"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>iFrameTest</title>

<script>
function setEditor(md) {
// document.editorFrame.document.body.innerHTML = "<b>This is a
test</breally.";
document.editorFrame.document.designMode=md;
}

function setBody() {

var msgTxt, bdy;

msgTxt = document.editorFrame.document.body.innerHTML;
bdy = document.getElementById("messageBody");
bdy.Value = msgTxt;

return true;
}

</script>

</head>
<body onLoad="setEditor('On');">

<form id="Form1" method="post" onsubmit="return setBody();">
<iframe class="bodyBox" name="editorFrame" id="editorFrame">
</iframe>
<input type="hidden" name="messageBody"/>
<input type="submit">
</form>

</body>
</html>

iframeTest.aspx.vb:

Public Class iFrameTest
Inherits System.Web.UI.Page

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Not Request.Form("messageBody") Is Nothing Then

If Request.Form("messageBody").Length 0 Then
Response.Write("got a value!")
Else
Response.Write("still nothing")
End If

End If

End Sub

End Class

Oct 3 '06 #2
Marina Levit [MVP] wrote:
Try adding: runat="server" to your form.
Makes no difference. The example I posted doesn't have any server
rendered controls anyway, so the only difference adding runat="server"
to the form is the server automatically inserts the hidden form
variable "__VIEWSTATE".

I tried making the form using server controls (changing the <input
type="submit"to <asp:Button ...and so on) and got the same results.

Oct 3 '06 #3
Tacky to repond to my own post, but: I figured out what the problem
was. My test file had the following bit of javascript:
...
msgTxt = document.editorFrame.document.body.innerHTML;
bdy = document.getElementById("messageBody");
bdy.Value = msgTxt;
...
The problem turned out to be "bdy.Value". Javascript is case
sensitive, and the attribute is properly accessed as "bdy.value". See
the difference?

Made that change and the page worked exactly as expected. Boy do I
feel foolish.

Oct 5 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Thomas | last post by:
Hy dudes, I have a strange problem. I dynamically create an IFrame with JavaScript and then fill in some content. Afterwards I want to switch to designMode. There the trouble starts. In Mozilla...
1
by: Börni | last post by:
Hi, I know that you can turn on the so called design mode for textareas in internet explorer. But it seems like mozilla can only turn it on for iframes. Basically i just want to know if someone...
1
by: IkBenHet | last post by:
Hello, I found this script to create a simple rich text form (http://programmabilities.com/xml/index.php?id=17): <html> <head> <title>Rich Text Editor</title> </head> <body>
14
by: Seth Russell | last post by:
I'm running Kevin Roth's rte box and i want to deactivate the ability to past inside the box. People sometimes paste outrageous things in there that might break my site. How can I deactivate the...
1
by: PC User | last post by:
I found this Rich Text Editor and I've been trying to recreate it in my own application. I've had trouble with the COMCTL.ImageListCtrl and the COMCTL.Toolbar to recreate the toolbar. And I've...
4
by: pbreah | last post by:
I'm doing a Rich Text Editor (WYSIWYG) in javascript for a game for kids. I'm doing a special case in with every keystroke from A-Z creates a background and foreground color for that letter, witch...
2
by: jceddy | last post by:
Well, there is something here I'm working on, and I have a problem that has several possible solutions...none of which I can figure out how to implement. Basically, I am creating a rich text...
9
by: pvsundarram | last post by:
hey, i am trying to cancel the keydown event for certain keycodes( for eg:- enter key ).But the cancelling of this event is not happening in firefox. Is there any way to cancel the event in the...
16
by: Neil | last post by:
I posted a few days ago that it seems to me that the Access 2007 rich text feature does not support: a) full text justification; b) programmatic manipulation. I was hoping that someone might...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.