ASP.Net 3.5 through C# in Visual Studio 2008.
Simple enough problem i think but I can’t find a solution to it online. I’ve a dropdownlist that was successfully posting back using the autopostback. I styled it using this jquery styler:
Selectbox Style
and since then it no longer posts back. This appears to be because Jquery is altering the code to facilitate the styling, which is fine, I just need to find a way to trigger the selectedindexchange event, or make jquery update the select box when someone changes the selection in the styled ‘version’ of the dropdownlist.
Any ideas?
This is the code Jquery produces:
<div class="test" sb="14935647" style="display: none;">
<select id="ctl00_Body_ucSets_rptSelections_ctl00_ddlAttributeSelection" class="dropdown" onchange="javascript:setTimeout('__doPostBack(\'ctl00$Body$ucSets$rptSelections$ctl00$ddlAttributeSelection\',\'\')', 0)" name="ctl00$Body$ucSets$rptSelections$ctl00$ddlAttributeSelection">
<option value="-1" selected="selected">Change Colour</option>
<option value="14">Red</option>
<option value="21">Black</option>
<option value="22">Pink</option>
<option value="23">Green</option>
</select>
</div>
<div id="sbHolder_14935647" class="sbHolder">
</div>
While this is what my actual C# code is:
<div class="test">
<asp:DropDownList ID="ddlAttributeSelection" runat="server" CssClass="dropdown"
OnSelectedIndexChanged="ddlAttributeSelection_selectedIndexChanged"
AutoPostBack="true" AppendDataBoundItems="true">
</asp:DropDownList>
</div>
It will not post back because what you are seeing on screen is not your DropDownList. If you inspect your DOM you will see that the jQuery has turned your DropDownList into an unordered list (
<ul>) with many list elements (<li>)Edit
From looking at the jQuery, there is an event which you can use
onchangewhich you will need to use to then call yourOnSelectedIndexChangedthrough javascript