MS Office Forum / General MS InfoPath Questions / January 2008
Web-enabled Form image control
|
|
Thread rating:  |
Dmitriy - 13 Dec 2007 22:01 GMT I have created a form that is web-enabled, but I had to find out the hard way that image control is not available for web-enabled forms. I am creating a simple shopping cart type form that gets a list of descriptions and prices from a sharepoint list. I also have a field that holds the URLs to the images of each item. I can display the data fine, but the pictures cannot be displayed since image control is not allowed. Please help me, I have to have pictures!!!
Clay Fox - 14 Dec 2007 03:18 GMT You could use frames. Checkout David's blog at http://www.infopathdev.com Otherwise you would have to use a link or pop up another window. I would think with code you could maybe update an image in the form itself.
 Signature Thanks
Clay Fox
Qdabra Software http://www.qdabra.com
InfoPathDev.Com The Largest InfoPath Forum in the World http://www.infopathdev.com
> I have created a form that is web-enabled, but I had to find out the hard way > that image control is not available for web-enabled forms. I am creating a [quoted text clipped - 3 lines] > displayed since image control is not allowed. Please help me, I have to have > pictures!!! S.Y.M. Wong-A-Ton - 14 Dec 2007 08:30 GMT One possible solution would be to host your form in a custom ASP.NET page (see http://msdn2.microsoft.com/en-us/library/aa701078.aspx) and then set up communication between the form and the ASP.NET page to show the images within the ASP.NET page. --- S.Y.M. Wong-A-Ton
> I have created a form that is web-enabled, but I had to find out the hard way > that image control is not available for web-enabled forms. I am creating a [quoted text clipped - 3 lines] > displayed since image control is not allowed. Please help me, I have to have > pictures!!! Dmitriy - 14 Dec 2007 16:29 GMT I tried looking around for a way to use code to display image, but could not find anything... ASP.net that might be a solution, but that means I almost have to redesign all of my data connections. I am using web service to submit Buyer's Cart data to an Sql database. Then I retrieve it using web service for review befor submiting to purchasing, which once again uses web service and send a custom html email. If any one can give me a start with coding in infopath to put insert images somehow that would be great. Or anything else that might help...
Dmitriy
> One possible solution would be to host your form in a custom ASP.NET page > (see http://msdn2.microsoft.com/en-us/library/aa701078.aspx) and then set up [quoted text clipped - 10 lines] > > displayed since image control is not allowed. Please help me, I have to have > > pictures!!! S.Y.M. Wong-A-Ton - 17 Dec 2007 08:26 GMT If you are just retrieving images to display items, you don't have to redesign any of your data connections. If you are submitting images to the web service, you might have to redesign and things might become a bit more complex, but it can still be done.
The link I provided actually contains all the code you need. The rest is just a matter of writing standard ASP.NET code and using ASP.NET controls: Your form retrieves the list of images through the web service, and passes this list, which is then just a list of image links to the ASP.NET page for display. Depending on how your form has been set up, you could even use a rich text box to display the images. This way you wouldn't have to use a custom web page, or pass anything between form and page. --- S.Y.M. Wong-A-Ton
> I tried looking around for a way to use code to display image, but could not > find anything... ASP.net that might be a solution, but that means I almost [quoted text clipped - 21 lines] > > > displayed since image control is not allowed. Please help me, I have to have > > > pictures!!! Dmitriy - 17 Dec 2007 17:57 GMT I am fairly new to infopath 2007 so can you help me out how a form can be set up for Rich text control to be used as a picture viewer... I would try .asp way, but truly this is a new combination for me (InfoPath and .net) and I don't have time to play around with it. So if possible please let me know more about Rich text control option.
Dmitriy
> If you are just retrieving images to display items, you don't have to > redesign any of your data connections. If you are submitting images to the [quoted text clipped - 36 lines] > > > > displayed since image control is not allowed. Please help me, I have to have > > > > pictures!!! S.Y.M. Wong-A-Ton - 18 Dec 2007 05:11 GMT You will have to write code to add the link to an image to the rich text box control. Just like you can add lines of text to a rich text field (see http://enterprise-solutions.swits.net/blog/?p=26), you can programmatically add an <img src="..."/> element, which points to an image, to a rich text field.
Again, I do not know how you have set up your form template, so am unable to provide more hints and tips to get your issue fully resolved. I'm currently short on time, but when I get a free moment, I'll write up an article on how to do it. The tips I've provided now should get you started. If you get stuck, let me know. --- S.Y.M. Wong-A-Ton
> I am fairly new to infopath 2007 so can you help me out how a form can be set > up for Rich text control to be used as a picture viewer... I would try .asp [quoted text clipped - 44 lines] > > > > > displayed since image control is not allowed. Please help me, I have to have > > > > > pictures!!! Dmitriy - 20 Dec 2007 21:09 GMT I got it to show up an image, but once again I am a little stuck.
I have data pulled from a SharePoint library to a repeating table. One of the fields is "thumb_url" which I need to use to display images for each row. However when I add a rich text to the BOUND repeating table, and in the code I add image reference, what happens is that it loops thru all the "thub_url" and grabs the last one and therefore for each row I get the same image of the last item.
Maybe I am missing something... When the rich text control is in the repeating table, it says that it cannot repeat there... Weird but maybe that has something to do with it.
I will continue on messing with it, maybe I will figure it out, but will appreciate any help.
Thank you, Dmitriy
> You will have to write code to add the link to an image to the rich text box > control. Just like you can add lines of text to a rich text field (see [quoted text clipped - 58 lines] > > > > > > displayed since image control is not allowed. Please help me, I have to have > > > > > > pictures!!! S.Y.M. Wong-A-Ton - 21 Dec 2007 01:12 GMT I would be interested to hear how you got the rich text box in the BOUND repeating table. Or did you use something else to display images?
I'm assuming that you are looping through a secondary data source to fill a repeating table with the links to the images. When setting a field in a repeating group, you need to specify which field you are setting by using a filter in your XPath expression. For example, if the XPath to the field in the repeating group is "group2/field1", you must use "group2[3]/field1" to set the field1 that is in the 3rd row. --- S.Y.M. Wong-A-Ton
> I got it to show up an image, but once again I am a little stuck. > [quoted text clipped - 77 lines] > > > > > > > displayed since image control is not allowed. Please help me, I have to have > > > > > > > pictures!!! Dmitriy - 21 Dec 2007 16:33 GMT Well, so far I had been populating the repeating control in the following way. I created the Secondary Data Connection and then I bound the repeating table up to it. So when I load the form it automatically loads the repeating table from the SharePoint list without the code.
I followed your suggestion and in one column of repeating table I inserted a RichText control. I tried to bind it to the same data source, but it was throwing errors and not letting me do that. So I bound it to a regular RichText field in the Main Data Source. At this point if I run the form it displayed all the information and an empty RichText fileld on every row of data.
So I wrote code that loops through the dataconnection and grabs the url string from Secondary Data Source "string url = rows.Current.SelectSingleNode("@thumb_url", NamespaceManager).Value"
Then I I followed your suggestion and the code from (enterprise-solutions) to populate txtRichText as image control:
XmlElement elm = doc.CreateElement("img", "http://www.w3.org/1999/xhtml"); XPathNavigator nav = MainDataSource.CreateNavigator(); XPathNavigator rtfNav = nav.SelectSingleNode("//my:txtRichText", NamespaceManager); elm.SetAttribute("src", "C:/bag_briefcase_jpg.jpg"); elm.SetAttribute("width", "75"); doc.AppendChild(elm); rtfNav.AppendChild(doc.DocumentElement.CreateNavigator());
Unfortunately when I do this, it repeats the same image for every row.
Now, I think that I will probably will have to disconnect the automatic population of the repeating table, and do it manually through a loop or something. I was trying to avoid that because one of the cool features of InfoPath 2007 is to do the connections without the code manipulation. Any ideas or thoughts would be appreciated.
Dmitriy
> I would be interested to hear how you got the rich text box in the BOUND > repeating table. Or did you use something else to display images? [quoted text clipped - 89 lines] > > > > > > > > displayed since image control is not allowed. Please help me, I have to have > > > > > > > > pictures!!! S.Y.M. Wong-A-Ton - 21 Dec 2007 22:44 GMT My first thought when I read your scenario was to create a repeating table in the Main data source and copy the values over from the secondary data source to be able to have a rich text field that displays the image. So no, I do not have any extra ideas and think you are on the right track. And if you need it, there is an example of populating a repeating table up on my web site (see http://enterprise-solutions.swits.net/infopath2007/programmatically-add-row-repe ating-table-xmlwriter.htm).
BTW, since you are creating a shopping cart and retrieving and submitting data through web services from/to a database, why did you not use a normal ASP.NET form? Are you storing the XML of the form anywhere? If not, I do not see the benefit of using an InfoPath form to do this. And as you can see, because of your image requirement and current limitation of web-based forms, you lose the benefit of being able to quickly create an InfoPath form without coding. So why not do everything in ASP.NET? I think you would have more flexibility that way. Just my 2 cents... --- S.Y.M. Wong-A-Ton
> Well, so far I had been populating the repeating control in the following > way. I created the Secondary Data Connection and then I bound the repeating [quoted text clipped - 128 lines] > > > > > > > > > displayed since image control is not allowed. Please help me, I have to have > > > > > > > > > pictures!!! Dmitriy - 26 Dec 2007 16:34 GMT Thanks so much for your help, but I am once again unsuccessful. Here is why!!! I went ahead and created a repeating table which I am filling through the code... I am able to use the XMLWriter to create the rows and fill in the text into them.
using (XmlWriter writer = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group1", NamespaceManager).AppendChild()) { writer.WriteStartElement("group2", myNamespace); writer.WriteElementString("field1", myNamespace, url); writer.WriteElementString("field2", myNamespace, description); writer.WriteElementString("field3", myNamespace, price); writer.WriteElementString("field4", myNamespace, qty); test = "<img src='" + url + "'>"; writer.WriteElementString("txtRichText", myNamespace, test); fillURL(url); writer.WriteEndElement(); writer.Close();
Since this is within XML it automatically converts (<> to < >) I tried to convert it back in the code, but unfortunately it does this after the code is parsed. So I have been unsuccessful in getting that converted back into (<>) tags. This was the last problem too, because to test I went ahead and saved the form as html page, and then viewed source and manualy replaced these tags and refreshed. It worked. But I cant do that by code or settings...
Anyway, my cooworkers suggested to recreate the whole cart in ASP. I am new to InfoPath and heard that it was made to easily create forms. Well I guess my requirements were not that simple... I am relly surprised that Microsoft wouldn't have regular image control for web-enabled forms.
Thanks for your help and patience... I know now that at least I can use RichText for images when not in repeating table. That is a cool trick... Thanks again...
Dmitriy
> My first thought when I read your scenario was to create a repeating table in > the Main data source and copy the values over from the secondary data source [quoted text clipped - 147 lines] > > > > > > > > > > displayed since image control is not allowed. Please help me, I have to have > > > > > > > > > > pictures!!! S.Y.M. Wong-A-Ton - 31 Dec 2007 04:28 GMT That you cannot add the link to a repeating table sounds odd. When I get a chance, I'll try it out, because I believe it should be possible. In addition, there are several ways to add rows to repeating table other than using an XMLWriter object; I might write something on that too.
Anyway, hope you have more luck creating the cart using ASP. --- S.Y.M. Wong-A-Ton
> Thanks so much for your help, but I am once again unsuccessful. Here is why!!! > I went ahead and created a repeating table which I am filling through the [quoted text clipped - 187 lines] > > > > > > > > > > > displayed since image control is not allowed. Please help me, I have to have > > > > > > > > > > > pictures!!! S.Y.M. Wong-A-Ton - 06 Jan 2008 03:24 GMT If you're still interested in implementing the functionality or just curious as to how you could have implemented it, I've posted an article here: http://enterprise-solutions.swits.net/browserforms/display-images-browser-form-r epeating-table-rich-text-box-control.htm --- S.Y.M. Wong-A-Ton
> Thanks so much for your help, but I am once again unsuccessful. Here is why!!! > I went ahead and created a repeating table which I am filling through the [quoted text clipped - 187 lines] > > > > > > > > > > > displayed since image control is not allowed. Please help me, I have to have > > > > > > > > > > > pictures!!! Dmitriy - 23 Jan 2008 19:31 GMT I will definately look into this. Thank you for posting it out there. Now I am having different issues with InfoPath form services and posted a question for that on the discussion board. When that gets resolved I can try your post. thanks again.
> If you're still interested in implementing the functionality or just curious > as to how you could have implemented it, I've posted an article here: [quoted text clipped - 193 lines] > > > > > > > > > > > > displayed since image control is not allowed. Please help me, I have to have > > > > > > > > > > > > pictures!!!
|
|
|