我想开发一个可以从两侧进行调整的多处理程序滑块。我的剧本为
<%@ 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();
}
}
提前致谢。请帮我找出错误。
答案 0 :(得分:2)
该错误是因为您在从Master继承的页面内工作并且您声明了两个ScriptManager。
您确实在Site.Master
内有ScriptManager,并且您也在此页面中添加了ScriptManager(Default.aspx)。
删除childPage中的scriptManager,因为该页面将使用Site.master的一个。
卸下:
<asp:ScriptManager runat="server" ID="ScriptManager1" EnablePartialRendering="true"/>