Note that there are some explanatory texts on larger screens.

plurals
  1. POListbox Javascript Multtiselect not working after upgrade to .Net 3.5
    primarykey
    data
    text
    <p>I have an application which is in .Net1.1 and upgraded to 3.5 using Visual studio 2008. </p> <p>There is page which is having a checkbox and a list box which is enabled and disabled using Javascript if enabled we can select the items in List and upon button click the selected items will be processed.</p> <p>The Selected items is working fine in .Net 1.1 but not in 3.5.I am giving sample code where I am facing the issue.The same code works fine in .Net1.1</p> <p>Below are the aspx lines </p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ListBox.aspx.cs" Inherits="WebApplication1.ListBox" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head&gt; &lt;title&gt;UsageReport&lt;/title&gt; &lt;script language="javascript"&gt; function isAllChecked() { var ctrlList = document.getElementById("lstUsers"); var allChecked = document.getElementById("chkAll"); var checked = allChecked.checked; if (checked) { ctrlList.disabled = true; unselectItems(); } else { ctrlList.disabled = false; } } function unselectItems() { var lstUsers = document.getElementById("lstUsers"); var list = lstUsers; for (var i = 0; i &lt; list.length; i ++) { list[i].selected = false; } list.selectedIndex = -1; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;/div&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt; &amp;nbsp;&lt;/td&gt; &lt;td&gt; &lt;asp:CheckBox ID="chkAll" Checked="True" runat="server" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &amp;nbsp;&lt;/td&gt; &lt;td&gt; &lt;asp:ListBox ID="lstUsers" runat="server" SelectionMode="Multiple" Enabled="false"&gt;&lt;/asp:ListBox&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &amp;nbsp;&lt;/td&gt; &lt;td&gt; &lt;asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Below are the lines for CodeBehind</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication1 { public partial class ListBox : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.chkAll.Attributes["onclick"] = "isAllChecked();"; lstUsers.DataSource = new string[] { "one", "two", "three" }; lstUsers.DataBind(); } } protected void Button1_Click(object sender, EventArgs e) { foreach (ListItem li in lstUsers.Items) { if(li.Selected) Response.Write(li.Value); } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload