I'm trying to use a textarea to grab user input as separate entries from a textarea.
My Textarea:
<asp:TextBox runat="server" TextMode="MultiLine" ID="uploadFieldChoices"></asp:TextBox>
Value of textarea as seen on textarea:
Value of textarea as retrieved by code:
Then I'll want store that in XML and use it to generate a dropdownlist that has those three entries as options.
To grab that what I'm trying to do is split the textarea value on line breaks and use that as my values to store as XmlNodes:
Code
If lstrFieldType = "Dropdown" Then
Dim lnodChoices As XmlNode = ldocFieldList.CreateElement("options")
Dim larrSplit() As String = uploadFieldChoices.Text.Split(Environment.NewLine)
For Each lstrOption As String In larrSplit
If Not lstrOption.Trim = "" Then
Dim lnodOption As XmlNode = ldocFieldList.CreateElement("option")
lnodOption.InnerText = lstrOption
lnodChoices.AppendChild(lnodOption)
End If
Next
lnodUploadField.AppendChild(lnodChoices)
End If
But so far I can't get larrSplit
to actually give me more than one value. Weird thing is, even though the above only gives me a single XmlNode, the xml file will actually have line breaks in the entry!
I know that a normal VB textbox has a ".lines" property that gives what I'm looking for, but isn't a property in the Web.Textbox control.
I've also tried:
Dim larrSplit() As String = uploadFieldChoices.Text.Split("\n\r")
Dim larrSplit() As String = uploadFieldChoices.Text.Split(vbNewLine)
Dim larrSplit() As String = uploadFieldChoices.Text.Split(vbCrLf)
But none work.
Why is this not working, and is there a better way completely different than the above?
Thanks!
Edit
Included code for textarea as it may be relevant.
Edit 2
Included images of textbox and value.