MultiHandleSliderExtender:错误-只能向页面添加一个ScriptManager实例
本文关键字:一个 实例 ScriptManager 添加 错误 -只 MultiHandleSliderExtender | 更新日期: 2023-09-27 18:26:36
我想开发一个可以从两侧调整的多处理程序滑块。我的脚本为
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication4._Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<asp:ScriptManager runat="server" ID="ScriptManager1" EnablePartialRendering="true"/>
<table>
<tr>
<td colspan="2">
<asp:UpdatePanel runat="server" ID="UpdatePanel" UpdateMode="Conditional">
<ContentTemplate>
<table>
<tr>
<td colspan="2">
<asp:TextBox runat="server" Id="txtSlider"></asp:TextBox>
<cc1:MultiHandleSliderExtender runat="server" ID="MultiHandleSliderExtender1"
ShowHandleDragStyle="false" BehaviorID="MultiHandleSliderExtender1"
TargetControlID="txtSlider" Length="200" ShowInnerRail="true"
EnableMouseWheel="false" OnClientDrag="Drag" Increment="1"
RaiseChangeOnlyOnMouseUp="true" EnableRailClick="false" OnClientDragEnd="DragEnd"
ShowHandleHoverStyle="true" Maximum="200" Minimum="1">
<MultiHandleSliderTargets>
<cc1:MultiHandleSliderTarget ControlID="rangeStart" />
<cc1:MultiHandleSliderTarget ControlID="rangeEnd" />
</MultiHandleSliderTargets>
</cc1:MultiHandleSliderExtender>
</br>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblStartRange" runat="server" Text=""></asp:Label>
</td>
<td>
<asp:Label ID="lblEndRange" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:HiddenField ID="rangeStart" runat="server" />
</td>
<td>
<asp:HiddenField ID="rangeEnd" runat="server" />
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
<script type="text/javascript">
var isDragging = false;
function Drag(sender, args) {
GetSliderRange($get("<%= rangeStart.ClientID %>").value, $get("<%= rangeEnd.ClientID%>").value);
}
function DragEnd(sender, args) {
<%-- //prevent postback on slider click
if ($get("<%= hdfTrackRangeStart.ClientID %>").value !== $get("<%= rangeStart.ClientID %>").value) {
$get("<%= btnLoadChart.ClientID %>").click();
//__doPostBack("<%= btnLoadChart.ClientID %>", "");
}
if ($get("<%= hdfTrackRangeEnd.ClientID %>").value !== $get("<%= rangeEnd.ClientID %>").value && $get("<%= hdfTrackRangeEnd.ClientID %>").value !== '0') {
$get("<%= btnLoadChart.ClientID %>").click();
//__doPostBack("<%= btnLoadChart.ClientID %>", "");
}--%>
}
function GetSliderRange(startV, endV) {
$get("<%= lblStartRange.ClientID %>").innerHTML = GetSliderText(arrRange[startV - 1], 's');
$get("<%= lblEndRange.ClientID %>").innerHTML = GetSliderText(arrRange[endV - 1], 'e');
// alert(arrRange[startV - 1]);
// PageMethods.SliderRange(startV, endV, this.callback);
}
function GetSliderText(r, p) {
var arrResult = r.split("--");
var strText = '';
if (p === 's') {
strText = "<b>From</b> Year: " + arrResult[0] + " Month: " + arrResult[1];
}
else {
strText = "<b>To</b> Year: " + arrResult[0] + " Month: " + arrResult[1];
}
return strText;
}
</script>
</asp:Content>
最初,我只是用page_load上的静态值作为进行检查
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
MultiHandleSliderExtender1.Minimum = 1;
MultiHandleSliderExtender1.Maximum = 200;
rangeStart.Value = MultiHandleSliderExtender1.Minimum.ToString();
rangeEnd.Value = MultiHandleSliderExtender1.Maximum.ToString();
}
}
提前谢谢。请帮我找出虫子。
中的错误是因为您在从Master继承的页面中工作,并且声明了两个ScriptManager。
请确保您在Site.Master
中有和ScriptManager,并且您还在该页面中添加了ScriptManager(Default.aspx)。
删除子页面中的scriptManager,因为此页面将使用Site.master的scriptManager。
删除:
<asp:ScriptManager runat="server" ID="ScriptManager1" EnablePartialRendering="true"/>