Solved

adding an "Other" option to a dropdown list

Posted on 2011-09-26
8
193 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Summary In SharePoint 2010 it is easy to create custom color themes to jazz up a site. Theme colors can also be created in PowerPoint 2010 with a few clicks. But how do the chosen colors actually look in the SharePoint site? The attached PowerPoint…
SharePoint Designer 2010 has tools and commands to do everything that can be done with web parts in the browser, and then some – except uploading a web part straight into a page that is edited in SPD. So, can it be done? Scenario For a recent pr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

21 Experts available now in Live!

Get 1:1 Help Now