Hi, i have problems with exchanging items between two select controls. Code works in IE but doesn't work in Firefox and Opera. Can anybody help me?
Thanks in advance, Dejan HTML: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="Test" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>test</title> <script type="text/javascript" defer="defer"> function add() { var testHelper = Test.GetTestHelper().value; var available = document.getElementById("available"); var selected = document.getElementById("selected"); testHelper.available = available.innerHTML; testHelper.selected = selected.innerHTML; Test.Add(testHelper, callback); testHelper = null; available = null; selected = null; } function remove() { var testHelper = Test.GetTestHelper().value; var available = document.getElementById("available"); var selected = document.getElementById("selected"); testHelper.available = available.innerHTML; testHelper.selected = selected.innerHTML; Test.Remove(testHelper, callback); testHelper = null; available = null; selected = null; } function callback(res) { var testHelper = res.value; var available = document.getElementById("available"); var selected = document.getElementById("selected"); alert(testHelper.available); alert(testHelper.selected); available.innerHTML = testHelper.available; selected.innerHTML = testHelper.selected; testHelper = null; available = null; selected = null; } </script> </head> <body> <form id="formTest" runat="server"> </form> <table> <tr> <td> <div id="available"> <select multiple="multiple" size="10" style="width: 150px"> <option value="2">test1</option> <option value="1">test2</option> </select> </div> </td> <td> <label id="labelAdd" onclick="javascript:add();void(0);">>></label><br /> <label id="labelRemove" onclick="javascript:remove();void(0);"><<</label> </td> <td> <div id="selected"> <select multiple="multiple" size="10" style="width: 150px"> </select> </div> </td> </tr> </table> </body> </html> CODE: public partial class Test : System.Web.UI.Page { [AjaxPro.AjaxMethod] public TestHelper GetTestHelper() { return new TestHelper(); } [AjaxPro.AjaxMethod] public TestHelper Add(TestHelper aoTestHelper) { Exchange(ref aoTestHelper.available, ref aoTestHelper.selected); return aoTestHelper; } [AjaxPro.AjaxMethod] public TestHelper Remove(TestHelper aoTestHelper) { Exchange(ref aoTestHelper.selected, ref aoTestHelper.available); return aoTestHelper; } private void Exchange(ref HtmlSelect aoFrom, ref HtmlSelect aoTo) { ArrayList loItems; ListItem loItem; loItems = new ArrayList(); for (int i = aoFrom.Items.Count - 1; i >= 0; i--) { loItem = aoFrom.Items[i]; if (loItem.Selected) { loItems.Add(loItem); aoFrom.Items.Remove(loItem); } } for (int i = loItems.Count - 1; i >= 0; i--) aoTo.Items.Add((ListItem)loItems[i]); } } public class TestHelper { public HtmlSelect available = null; public HtmlSelect selected = null; } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ajax.NET Professional" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/ajaxpro The latest downloads of Ajax.NET Professional can be found at http://www.ajaxpro.info/ Don't forget to read my blog at http://weblogs.asp.net/mschwarz/ -~----------~----~----~----~------~----~------~--~---
