Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox to textbox

Status
Not open for further replies.

tsp1lrk

IS-IT--Management
May 30, 2001
103
US
Hello,

I have an ASP.NET/VB.NET app; I'm using a datagrid and selecting items; as the items are selected, they are going to a listbox. Once the user has selected what they want, they click a button to add it to the Parent page. How can I get those listbox items back to the other page into a textbox field?

Thanks,
Lisa
UPS
 
Create an array variable with the values you want to copy. Add each item to the array list as the user selects the item from the grid. Put the array into session.

When you load the next page, retrieve the array from session and loop through it adding the text you want to the listbox for each value in the array.
 
Any sample code available to assist? Thanks for the information- I actually got it into the parent page, but I only have 1 item, not all of them. Looks like it's taking ONLY the last one, It's actually a Javascript within the .NET control, My syntax for some reason is off:

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim sScript As String = ""
Dim item As ListItem
For Each item In ListBox1.Items

sScript &= "<script language=javascript>"
sScript &= " window.opener.F1.txthold.value = '" & item.Text & "';"

sScript &= " window.close();"
sScript &= "</script>"
Response.Write(sScript)
'message2.Text &= item.Text & "<br>"
Next

End Sub

Any ideas?
Lisa
UPS
 
Code:
            sScript &= "<script language=javascript>"
            sScript &= " window.opener.F1.txthold.value =  '" & item.Text & "';"

            sScript &= " window.close();"
            sScript &= "</script>"

should be

Code:
            sScript &= "<script language=javascript>"
            sScript &= " window.opener.F1.txthold.value  +=  '" & item.Text & "';"

            sScript &= " window.close();"
            sScript &= "</script>"


--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
and also outside the loop, make sure you clean the window.opener.F1.txthold.value
Code:
window.opener.F1.txthold.value = '';

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top