Click here to Skip to main content
15,916,692 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I am creating a forums like site and i have implemented a (simple) richtext area. I am able to fetch the input at server. But i dont have any idea on how to retrieve this from the server and present this to the user.
XML
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <script language="javascript" type="text/javascript">
        function def()
        {
            var testframe = document.createElement("iframe");
            testframe.name = testframe.id = "textEditor";
            testframe.width = 500;
            testframe.runat="server";

            if (testframe.addEventListener)
            {
                testframe.addEventListener("load",function(e){this.contentWindow.document.designMode = "on";}, false);
            }
            else if (testframe.attachEvent)
            {
                testframe.attachEvent("load", function(e){this.contentWindow.document.designMode = "on";});
            }

            frame.appendChild(testframe);

            textEditor.document.designMode="on";
            textEditor.document.open();
            textEditor.document.write('<head><style type="text/css">body{ font-family:arial; font-size:14px;}</style> </head><div id="txt"></div>');
            textEditor.document.close();
            textEditor.focus();
        }

        function fontEdit(x,y)
        {
            textEditor.document.execCommand(x,"",y);
            textEditor.focus();
        }
        function setHidden()
        {
            window.alert(textEditor.document.getElementById('txt').document.body.innerHTML);
            document.getElementById('cnt').value = textEditor.document.getElementById('txt').document.body.innerHTML;
            window.alert(document.getElementById('cnt').value);

        }

    </script>
</head>
<body onload="def()">
    <div id="frame"></div>
    <input type="button" id="btnBold" value="B" onclick="fontEdit('bold')" />
    <input type="button" id="btnItalics" value="I" onclick="fontEdit('italic')" />

    <form id="form1" runat="server">
        <input type="hidden" name="cnt" id="cnt"/>
        <asp:Button ID="btnSubmit" Text="submit" runat="server" OnClientClick="setHidden()" OnClick="btnSubmit_onClick" />
    </form>
</body>
</html>

It would be great if some one could give me an insight into this. I actually want Iframe to be part of datagrid and after binding i want to assign the value to the Iframe to display the contents.The code you see above is for the page where the user enters comments. But the contents of the post will be displayed in a datagrid.
Of i forgot this is the datagrid i am talking abt

XML
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BorderStyle="Solid" ShowHeader="false" HeaderStyle-BorderStyle="None">
               <Columns>
                   <asp:TemplateField ShowHeader="false">

                       <ItemTemplate>
                           <table>
                               <tr>
                                   <td align="center">
                                       <asp:Label ID="lblCommentTitle" runat="server" ForeColor="Blue" Font-Italic="true" Text='<%# Bind("CommentTitle") %>'></asp:Label>
                                   </td>
                               </tr>
                               <tr>
                                   <td align="right">
                                       <asp:Label ID="lblCommentedBy" runat="server" ForeColor="Black" Text='<%# Bind("CommentedBy","Commented by {0}") %>'></asp:Label>
                                   </td>
                               </tr>
                               <tr>
                                   <td align="left">
                                       <asp:TextBox ID="txtCommentBody" runat="server" Width="493px" Height="196px" TextMode="MultiLine" ReadOnly="true"  Wrap="true" Text='<%# Bind("CommentBody") %>'></asp:TextBox>
                                   </td>
                               </tr>
                           </table>
                       </ItemTemplate>
                   </asp:TemplateField>

Here instead of the TextBox, I want an iframe.
please help me.

Thanks in Advance.
Posted
Updated 28-Jun-11 18:35pm
v3

You could you use javascript to create iframe element using create element
you need to invoke the js on some events or your best way your design goes.
 
Share this answer
 
v2
Use Javascript to create your Iframe.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900