473,408 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Adding / removing <asp:ListBox elements client-side

Hi,

Looking for some advice again...

Imagine two ListBox controls denoting something like students and team
membership e.g. many students can be members of many teams (e.g. the hockey
team, the football team, the athletics team etc).

Team membership is managed on a standard web page with two ListBox
controls - the one on the left shows which team(s) the student is not a
member of, and the one on the right shows the team(s) which the student is a
member of e.g.

<asp:TextBox ID="txtStudent" runat="server" /><br />
<br />
<table>
<tr>
<td><b>Not member of</b></td>
<td><b>Member of</b></td>
</tr>
<tr valign="middle">
<td align="center">
<asp:ListBox ID="lstNotMemberOf" Runat="server" Rows="15"
Width="200px" />
</td>
<td align="center">
<asp:ListBox ID="lstMemberOf" Runat="server" Rows="15"
Width="200px" />
</td>
</tr>
</table>

When the page is first loaded, the textbox is populated with the student's
name, and the two listboxes are populated with the lists of teams of which
that student is not a member / is a member respectively.

In order to minimise postbacks, network traffic and database access, there
are client-side buttons which "toggle" the team membership. I.e, you
highlight one of the elements in one of the lists and hit the button, which
calls a JavaScript function to remove that element from the box it's
currently in to the other box.

All of this is working perfectly. However, the problem lies when the user
has finished making modifications to the student's team membership, and hits
the Save button. This posts back to the server but, of course, the updated
collection of elements in the two ListBoxes is not persisted across the
postback.

To get round this, I'm using what seems to be the "standard" workaround for
this problem i.e. two hidden textboxes containing the updated collection of
elements, as these ARE persisted across the postback. See what I mean here:
http://www.velocityreviews.com/forum...splistbox.html

However, I'm wondering if there is a better / more efficient way of
achieving this...?

Any assistance gratefully received.

Mark

P.S. ASP.NET 2 / VS.NET 2005, all the latest patches etc.
Sep 23 '06 #1
2 3601
Obvious question, but are you reloading the lists each time the page is
loaded? If so, that would be resetting your lists. If you are, just put a
check for IsPostBack round the list population code and only run it
IsPostBack is false.

Cheers,

Tim.
Sep 23 '06 #2
"Tim Payne" <ti*@attackmonkey.co.ukwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Obvious question, but are you reloading the lists each time the page is
loaded? If so, that would be resetting your lists. If you are, just put a
check for IsPostBack round the list population code and only run it
IsPostBack is false.
Please re-read the OP...
Sep 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Fresh Air Rider | last post by:
Hello Could anyone please explain how I can pass more than one arguement/parameter value to a function using <asp:linkbutton> or is this a major shortfall of the language ? Consider the...
5
by: Ken Dopierala Jr. | last post by:
Hi, This is just a query about what people use most. Up until today I've been using <asp:Table> tags to build my tables. We just outsourced our HTML design to a local guy and when I got it back...
4
by: z. f. | last post by:
Hi, I'm having an aspx page with a server form. i have a grid with a delete button and below the grid, another area with inputs for inserting new values and an "add" button for submiting the...
7
by: Venus | last post by:
Hello, I am trying to generate a dynamic form at runtime and would like to do it using "<asp: ..." form elements as follows Build up the string that is placed somewhere in the HTML code the...
5
by: George Durzi | last post by:
I currently have an href inside of an asp:repeater <a href='<%# String.Concat("PDFReader.aspx?id=", DataBinder.Eval(Container.DataItem, "ProductUniqueId")) %>' target="_blank">View</a> ...
1
by: Danny Ni | last post by:
Hi, I use the <asp:xml> control, xml and xslt to generate a HTML for users to input data, here is my HTML snippet in a web form: <asp:Xml id="Xml1" runat="server" TransformSource="entry.xsl"...
3
by: Ryan Taylor | last post by:
Hello. I have an application where I need the user to be able to add items to a listbox. I've implemented this via javascript. The listbox is an <asp:ListBox>. However, when the user submits the...
1
by: Joo Park | last post by:
How do you have a hyperlink that will open up a new window which passes in selected items from a listbox that is on the same page as the hyperlink using <asp:Hyperlink>? thx in advance!
0
by: CharlesA | last post by:
Hi folks, I'm using ASP.net 1.1 with C# I've got this kind of thing going <div class="row"> <label class="col1">Rm Name</label> <asp:textbox id="txtRM" runat="server" cssclass="col2"...
4
by: Kevin Blount | last post by:
As mentioned before, I'm creating a multi-lingual page where the text of the page comes from a database. This page includes a registration form which asks for address information, including the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.