Why does attaching an eventhandler in Javascript stop my server side event firing?
<p>I've been doing C# for years but ASP.NET for not so long and this has me stumped.</p>

<p>In my troubleshooting example I have a dropdownlist in an ASP.NET page, it has four items in it, I have a serverside event that fires on <code>selectedindexchanged</code>, it all works great in this scenario. </p>

<p>However, if (as i have in my evolved code) I set a Javascript handler for the "onchange" event, (which launches an alert) the alert works fine, but the server side event no longer fires... I'm sure I'm missing something obvious.</p>

<p>Important notes: <code>Autopostback</code> is set to true on the dropdownlist control, viewstate is enabled, the Javascript event handler returns true</p>

<p>Anyone? </p>

<p>It's not that I have to manually wire up the <code>__doPostBack</code> is it?</p>

<p>Any help greatly appreciated.</p>

<p><strong>Edit</strong></p>

<p>ok here is the code first the codebehind</p>

<pre><code>using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

namespace TestEvents
{
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected override void OnPreRender(EventArgs e)
    {

        ClientScriptManager csm = Page.ClientScript;
        if (!csm.IsClientScriptBlockRegistered("NotesChangeScript"))
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("\r\n &lt;script type=\"text/javascript\"&gt; \r\n");
            sb.Append(" //&lt;![CDATA[ \r\n");
            sb.Append(" var changesCount = 0; \r\n");

            sb.Append(" function selection_handler()\r\n");
            sb.Append("{ \r\n");
            sb.Append(" changesCount += 1;\r\n");
            sb.Append(" alert('i changed on the client!'); \r\n");
            sb.Append(" return true; \r\n");
            sb.Append(" } \r\n");

            sb.Append(" function SetUpNotesHandler() \r\n");
            sb.Append("{ \r\n");
            sb.Append("          var ctrls = document.getElementsByTagName(\"SELECT\");\r\n");
            sb.Append("          for(i=0;i&lt;ctrls.length;i++)\r\n");
            sb.Append("                  {\r\n");
            sb.Append("                     ctrls[i].onchange = selection_handler; \r\n");
            sb.Append("                 }\r\n");
            sb.Append("}\r\n");


            sb.Append(" //]]&gt; \r\n");
            sb.Append("&lt;/script&gt;");

            csm.RegisterClientScriptBlock(this.GetType(), "NotesChangeScript", sb.ToString(), false);

            StringBuilder initScript = new StringBuilder();
            initScript.Append("&lt;script type=\"text/javascript\" &gt;\r\n");
            initScript.Append(" //&lt;![CDATA[\r\n");
            initScript.Append("  SetUpNotesHandler(); \r\n");
            initScript.Append(" //]]&gt; \r\n");
            initScript.Append("&lt;/script&gt; \r\n");
            csm.RegisterStartupScript(this.GetType(), "StartUpKey", initScript.ToString(),false);
            base.OnPreRender(e);
        }

    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Response.Write("i hit the server event");
    }
}
</code></pre>

<p>}</p>

<p>and here is the markup for the page</p>

<pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true"     CodeBehind="Default.aspx.cs"    Inherits="TestEvents._Default" %&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 runat="server"&gt;
&lt;title&gt;problem&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form id="form1" runat="server"&gt;
&lt;div&gt;
    &lt;asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"&gt;
        &lt;asp:ListItem&gt;Numero Uno&lt;/asp:ListItem&gt;
        &lt;asp:ListItem&gt;Numer Deux&lt;/asp:ListItem&gt;
        &lt;asp:ListItem&gt;Number Three&lt;/asp:ListItem&gt;
        &lt;asp:ListItem&gt;Nomina Quatros&lt;/asp:ListItem&gt;
    &lt;/asp:DropDownList&gt;
    &lt;asp:HiddenField ID="hdnFieldChange" runat="server" /&gt;
&lt;/div&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
