javascript - Input Data To SharePoint RichText Control By WinForms WebBrowser Control -
i need edit value in sp rich text field via winforms web browser control. other controls (input tags) easy , can change value quite simply. however, not simple rich text. headed on to: http://blog.drisgill.com/2007_05_01_archive.html
and got ideas. @ first, tried creatign javascript function , adding page:
function getrichtextrange(strbaseelementid) var doceditor=rte_geteditordocument(strbaseelementid); if (doceditor == null) { return; } var selection = doceditor.selection; var range = selection.createrange(); return range; }
however, every time call this, null value back. tried instead:
object doceditor = document.invokescript("rte_geteditordocument", new object[] { fieldname }); ihtmldocument2 doc = (ihtmldocument2)doceditor; ihtmlselectionobject selection = doc.selection; ihtmltxtrange textrange = (ihtmltxtrange)selection.createrange(); textrange.pastehtml(value);
well, getting error on second line: "unable cast object of type 'system.dbnull' type 'mshtml.ihtmldocument2"
i not sure if casting correct object type anyway, in case, seems getting rte_geteditordocument function of system.dbnull.
all want myrichtexthtmlelement.setattribute("value", html); cannot done.
to make things worse, new javascript , i'm more of winforms guy, html not hot stuff. below html richtext field:
<tr> <td nowrap="true" valign="top" width="190px" class="ms-formlabel"> <h3 class="ms-standardheader"> <nobr>richtext</nobr> </h3> </td> <td valign="top" class="ms-formbody"> <!-- fieldname="richtext" fieldinternalname="richtext" fieldtype="spfieldnote" --> <span dir="none"> <div class='ms-rtestate-field ms-rtefield' style=''> <div id='ctl00_m_g_29d60052_5630_4981_8452_850a87a50b56_ctl00_ctl05_ctl07_ctl00_ctl00_ctl04_ctl00_ctl00_textfield_inplacerte_label' style='display:none'>rich text editor </div> <div class=' ms-rtestate-write ms-rteflags-0' id='ctl00_m_g_29d60052_5630_4981_8452_850a87a50b56_ctl00_ctl05_ctl07_ctl00_ctl00_ctl04_ctl00_ctl00_textfield_inplacerte' style='min-height:84px' aria-labelledby='ctl00_m_g_29d60052_5630_4981_8452_850a87a50b56_ctl00_ctl05_ctl07_ctl00_ctl00_ctl04_ctl00_ctl00_textfield_inplacerte_label' contenteditable='true' > <div class="externalclassd74b4d64d01941cdb34619757aaa30d8"> <html> <body> <h4>a definition list:</h4> <dl> <dt>coffee</dt> <dd>black hot drink</dd> <dt>milk</dt> <dd>white cold drink</dd> </dl> </body> </html> </div> </div> <div style="clear:both;"></div> </div> <span dir="ltr"> <input name="ctl00$m$g_29d60052_5630_4981_8452_850a87a50b56$ctl00$ctl05$ctl07$ctl00$ctl00$ctl04$ctl00$ctl00$textfield_spsave" type="hidden" id="ctl00_m_g_29d60052_5630_4981_8452_850a87a50b56_ctl00_ctl05_ctl07_ctl00_ctl00_ctl04_ctl00_ctl00_textfield_spsave" /> </span> </span> </td> </tr>
anyone got ideas? thanks!
do have use winforms webbrowser control? 1 use whatever html code editor wanted in winform , capture results , use sharepoint web services or object model(depending on use case) update item alternative option.
Comments
Post a Comment