How can I grab the XHTML out of a RichTextBox control in my webservice? - InfoPath Dev
in

InfoPath Dev

How can I grab the XHTML out of a RichTextBox control in my webservice?

Last post 05-25-2010 06:26 AM by showet. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 05-20-2010 01:24 PM

    How can I grab the XHTML out of a RichTextBox control in my webservice?

    I am trying to create an InfoPath 2007 form that allows the user to enter information into a richTextBox control.  In my web service I want to grab the xhtml that is in the richTextBox and save it as a string into my database so I can display it later in a different application.

    I am using Visual Studio and C# but I can't seem to get the "content" of the richTextBox into a string.  I don't want just the text that was entered, I need the xhtml that is in the richTextBox.

    In my webservice if I just attempt get the value of my richTextbox like the following, it returns the name of the richTextBox control.

    string strRichText = myInstructs.txtRichText.ToString();

    (myInstructs is a class created from mySchema)

    So how do I get the "contents" of the richTextBox into a string?

  • 05-20-2010 10:41 PM In reply to

    Re: How can I grab the XHTML out of a RichTextBox control in my webservice?

    may be you should try for innerxml

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 05-24-2010 09:10 AM In reply to

    Re: How can I grab the XHTML out of a RichTextBox control in my webservice?

    I don't find any option to get InnerHTML.

    The only option I have is to convert it to a string.  DotNet recognizes this as a richtext field as distinct from a string field so I have to convert it to something, but string is the only real option I have.

    I can't see where DotNet has a richText datatype even though it recognizes that InfoPath does have one.

  • 05-24-2010 10:10 AM In reply to

    Re: How can I grab the XHTML out of a RichTextBox control in my webservice?

     Most likely, the rich text contents of your field are being deserialized as an array of XmlNodes called Any.  If that's the case, you should be able to get the XHTML with something like this:

    StringBuilder richText = new StringBuilder();
    foreach (XmlNode node in myInstructs.txtRichText.Any)
    {
         richText.Append(node.OuterXml);
    }
    string richTextStr = richText.ToString();

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 05-24-2010 11:32 AM In reply to

    Re: How can I grab the XHTML out of a RichTextBox control in my webservice?

    When I do this I get the same thing that I get by just trying to get a string value.  richTextStr = "namespace.RichTextFieldName" (of course this is my actual namespace and my richText field name)

    I even tried node.InnerXML, node.InnerText, and node.Value but I get the same results for all of them, just the namespace and field name.

    I am wondering if this indicates some other error because I continue to get the same thing even when I change what I am looking for?

  • 05-24-2010 11:44 AM In reply to

    Re: How can I grab the XHTML out of a RichTextBox control in my webservice?

    Could you show us the exact code you tried, based on my recent post?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 05-24-2010 11:54 AM In reply to

    Re: How can I grab the XHTML out of a RichTextBox control in my webservice?

    I used the exact code you sent.  I copied it and pasted it into by webService then I changed the last string variable from richTextStr to strRichText because that is the varable I pass to my webService.  (This is the only occurance of strRichText in my webservice).

    The code looks like this:

    StringBuilder richText = new StringBuilder();foreach (XmlNode node in myInstructs.txtRichText.Any)

    {

    richText.Append(node.OuterXml);

    }

    string strRichText = richText.ToString();

    Everything compiles and runs with no detectable error.

  • 05-24-2010 09:50 PM In reply to

    Re: How can I grab the XHTML out of a RichTextBox control in my webservice?

    I find it very hard to believe that even after changing it to that code, strRichText still has the value "namespace.fieldName." Are you sure you're not making some mistake in redeploying the web service and that it's not running a previous build of the code?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 05-25-2010 06:26 AM In reply to

    Re: How can I grab the XHTML out of a RichTextBox control in my webservice?

    I rebuilt everything and now it is working.  Since I rebuit everything I am not sure what it was that was changed to make it work.

    I thank you very much for your help, I had put a lot of time into this and I was just not getting anywhere.

    Don't know what to say but just thanks!

Page 1 of 1 (9 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.