Solved

adding an "Other" option to a dropdown list

Posted on 2011-09-26
8
194 Views
Last Modified: 2012-05-12
looking for a bit of advice on the structure of my form...

I have a dropdown with 3 or 4 hard coded values, and I want to add an "Other" option where if selected, a textbox would appear below it where the could enter an a new option. When they then click the SAVE button, I want to be able to save that new option. Obviously, I would need to keep all of the options stored somewhere, I was just wondering what the common practice for this scenario would be. I don't expect more than 10 or so options to ever be added, so would saving it to a list be overkill, or would it be better to save it directly to an xml document and keep that somewhere on the site? if thats the way to go, I'd love to see some examples on how to do this via VB.NET, as I have a custom save function written in VSTA to handle the form saves.
0
Comment
Question by:Big Monty
  • 5
  • 3
8 Comments
 
LVL 14

Expert Comment

by:abhitrig
ID: 36712418
Considering Secondary DataSources are lost, you have the following options:
1. Store the data in SP list
2. Store in DB
3. Store it an XML file.

I would recommend to use a SP list as it will be relatively easy to manage it from Infopath.
0
 
LVL 32

Author Comment

by:Big Monty
ID: 36717829
i've decided to use an xml file, do you know of any tutorials or online examples that would help me write to it? I know how to read from it, just not store the newly added option in it.
0
 
LVL 14

Expert Comment

by:abhitrig
ID: 36718268
I son't think you can save secondary datasources (which you are using to get the xml)
So you have two options:

1. Create a webservice to modify the xml and then call the webservice from IP
2. Use C# code to modify the xml directly. This will be similar to ASP.NET programming where you will edit the xml on the save event of the IP form.
0
 
LVL 32

Author Comment

by:Big Monty
ID: 36718293
My apologies I should have been more clear. I want to be able to do this via code as I have a custom save function already in place and need to add this to it. I prefer FB.net but c# would help as well.
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 14

Accepted Solution

by:
abhitrig earned 500 total points
ID: 36718662
0
 
LVL 32

Author Comment

by:Big Monty
ID: 36719255
these look good, i'll check these out more in depth and get back to you tomorrow.
0
 
LVL 32

Author Comment

by:Big Monty
ID: 36913236
so, after playing around with it a bit, i got it working somewhat. I can get it to save to my local disk, but not on the server. In order to open up the file, I needed to pass the current users credentials over, which I did below. My problem now is that the very last line of code throws an error "Invalid URI". It looks like the save command won't accept a url as a parameter, is there any way around this?
Dim resolver As XmlResolver = New XmlUrlResolver
            resolver.Credentials = System.Net.CredentialCache.DefaultCredentials

            'Dim settings As XmlReaderSettings = New XmlReaderSettings
            'settings.XmlResolver = resolver
            'Dim reader As XmlReader = XmlReader.Create("http://some sharepoint url/Dev/Shared%20Documents/vendors.xml")

            Dim reader As XmlTextReader = New XmlTextReader("http://some sharepoint url/Dev/Shared%20Documents/vendors.xml")
            reader.XmlResolver = resolver

            Dim xd As XmlDocument = New XmlDocument
            xd.Load(reader)

            Dim cr As String = System.Environment.NewLine
            Dim newPerson As String = _
                "<Vendor value=""some value"" /> "

            ' Create a new XmlDocumentFragment for our document.
            Dim docFrag As XmlDocumentFragment = xd.CreateDocumentFragment()

            ' The Xml for this fragment is our newPerson string.
            docFrag.InnerXml = newPerson

            ' The root element of our file is found using
            ' the DocumentElement property of the XmlDocument.
            Dim root As XmlNode = xd.DocumentElement

            ' Append our new Person to the root element.
            root.AppendChild(docFrag)

            ' Save the Xml.
            xd.Save("http://some sharepoint url/Dev/Shared%20Documents/vendors.xml")

Open in new window

0
 
LVL 32

Author Closing Comment

by:Big Monty
ID: 36962498
this got me going in the right direction, but am still having problems with permissions
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Scenario: Let’s say you have a quote worksheet in Excel that you use to work up sales figures and such for your clients. You utilize SharePoint to manage and keep track of these documents. You would like values from your worksheet to populate Sh…
Before you can digitally sign infopath forms, you must have a digital certificate. Microsoft Certificate Services will need to be enabled on a Windows Server 2008 to facilitate the creation and verification of the digital certifciates on the web ser…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now