I am trying t use the multihandlesliderextender (from the Ajax Toolkit) to make a filter option on the price in a webshop. When a new price is selected, it has to reload everything (and do a lot of behind the scenes code).
I've used this article here http://forums.asp.net/p/1397694/3022998.aspx as inspiration, and the primary idea is to use JavaScript to make the postback.
I have the following error when running my page: "Microsoft JScript runtime error: Unable to set value of the property 'Handle': object is null or undefined" .
I guess it's because the JavaScript can't find the control, but I don't get why it doens't work as I use ClientIdMode to make sure ID should match (and looking in the generated HTML it should work).
Thanks!
I've the following markup:
<asp:TextBox ID="txtSlider" runat="server" AutoPostBack="true" ></asp:TextBox>
<asp:MultiHandleSliderExtender ID="MultiHandleSliderExtender1" BehaviorID="MultiHandleSliderExtender1"
runat="server" TargetControlID="txtSlider" Length="120" TooltipText="{0}" OnClientDragEnd="ValueChangedHandler">
<MultiHandleSliderTargets>
<asp:MultiHandleSliderTarget ControlID="LeftHandle" />
<asp:MultiHandleSliderTarget ControlID="RightHandle" />
</MultiHandleSliderTargets>
</asp:MultiHandleSliderExtender>
<br/><br/>
<asp:TextBox ID="LeftHandle" runat="server" ClientIDMode="Static"></asp:TextBox>
<asp:HiddenField ID="HiddenField1" runat="server" ClientIDMode="Static" />
<asp:Label ID="RightHandle" runat="server" ClientIDMode="Static"></asp:Label>
<asp:HiddenField ID="HiddenField2" runat="server" ClientIDMode="Static" />
<asp:Button ID="Button1" runat="server" Text="Button"
Style="display: none" onclick="Button1_Click" />
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
And in my header the following JavaScript:
<script type="text/javascript">
function ValueChangedHandler(sender, args) {
$get("HiddenField1").value = $get("LeftHandle").value;
$get("HiddenField2").value = $get("RightHandle").value;
__doPostBack("Button1", "Click");
}
</script>
I solved this by updating in the page_load event instead, like this:
var controlId = Request.Form["__EVENTTARGET"];
var control = Page.FindControl(controlId);
if(control.ID == sliderTwo.ID)
{
SetupPriceFilter(p);
}
else if (control.ID == sliderAge.ID)
{
SetupAgeFilter( p);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.