在滑块上手动更改值不会更新结果。网络平台
我的问题是这样的:当我在滑块上手动更改值时,即在文本框中输入值而不是拖动滑块,页面不会重新加载,因此看不到任何更改。
我尝试添加“OnTextChanged”监听器,但这不起作用。 我认为设置 AutoPostBack="true" 会导致页面在输入值时重新加载,但这也不起作用。
slidercode:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="IntervalSlider.ascx.cs" Inherits="DynamicForm.UserControls.Filter.IntervalSlider" %>
<tr>
<td>
<asp:Label runat="server" ID="lblHeader"></asp:Label><asp:Image runat="server" ID="infoImg" Visible="false" ImageUrl="~/HTML/icons/info_16.png" />
</td>
<td class="filterSpacerCol"> </td>
<td>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:TextBox ID="txtMin" size="6" style="text-align:right;" runat="server" AutoPostBack="true" value=""></asp:TextBox>
</td>
<td width="150px"><div runat="server" id="divSlider" style="margin-top:0px"> <asp:TextBox ID="txtCurrentValue" runat="server" AutoPostBack="true" OnTextChanged="txtCurrentValue_TextChanged" value="20" style="display:none;" />
<ajax:MultiHandleSliderExtender ID="MultiHandleSliderExtenderMinMax" runat="server" Minimum="0" Maximum="10" TargetControlID="txtCurrentValue">
<MultiHandleSliderTargets>
<ajax:MultiHandleSliderTarget ControlID="txtMin" />
<ajax:MultiHandleSliderTarget ControlID="txtMax" />
</MultiHandleSliderTargets>
</ajax:MultiHandleSliderExtender>
</div>
</td>
<td>
<asp:TextBox ID="txtMax" size="6" style="text-align:right;" runat="server" AutoPostBack="true" value="" />
</td>
</tr>
</table>
</td>
</tr>
底层代码:
public partial class IntervalSlider : System.Web.UI.UserControl, IRange
{
protected void Page_Load(object sender, EventArgs e)
{
lblHeader.Text = HttpUtility.HtmlEncode(HeaderText);
if ((ToolTipText ?? "") != "")
{
infoImg.Visible = true;
infoImg.ToolTip = ToolTipText;
lblHeader.ToolTip = ToolTipText;
}
divSlider.Attributes.Add("title", ToolTipText);
txtMax.ToolTip = ToolTipText;
txtMin.ToolTip = ToolTipText;
foreach (AjaxControlToolkit.MultiHandleSliderTarget target in MultiHandleSliderExtenderMinMax.MultiHandleSliderTargets)
target.ControlID = MultiHandleSliderExtenderMinMax.Parent.FindControl(target.ControlID).ClientID;
}
public string HeaderText { get; set; }
public string ToolTipText { get; set; }
protected void txtCurrentValue_TextChanged(object sender, EventArgs e)
{
//FilterChanged(sender, e);
}
public event EventHandler FilterChanged;
public string MaxFilterValue
{
get { return txtMax.Text; }
}
public int Minimum
{
get { return MultiHandleSliderExtenderMinMax.Minimum; }
set
{
MultiHandleSliderExtenderMinMax.Minimum = value;
txtMin.Text = value.ToString();
}
}
public int Maximum
{
get { return MultiHandleSliderExtenderMinMax.Maximum; }
set {
int minValue = value;
MultiHandleSliderExtenderMinMax.Maximum = minValue;
txtMax.Text = minValue.ToString();
}
}
public string MinFilterValue
{
get { return txtMin.Text; }
}
}
}
有人知道如何解决这个问题吗?
My problem is this: when I change the values manually on a slider, that is input the value in the textbox instead of dragging the slider, the page is not reloaded so no change is visible.
I've tried adding a "OnTextChanged"-listener but that doesn't work.
I thought setting AutoPostBack="true" would cause the page to reload when inputting values, but that didn't work either.
The slidercode:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="IntervalSlider.ascx.cs" Inherits="DynamicForm.UserControls.Filter.IntervalSlider" %>
<tr>
<td>
<asp:Label runat="server" ID="lblHeader"></asp:Label><asp:Image runat="server" ID="infoImg" Visible="false" ImageUrl="~/HTML/icons/info_16.png" />
</td>
<td class="filterSpacerCol"> </td>
<td>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:TextBox ID="txtMin" size="6" style="text-align:right;" runat="server" AutoPostBack="true" value=""></asp:TextBox>
</td>
<td width="150px"><div runat="server" id="divSlider" style="margin-top:0px"> <asp:TextBox ID="txtCurrentValue" runat="server" AutoPostBack="true" OnTextChanged="txtCurrentValue_TextChanged" value="20" style="display:none;" />
<ajax:MultiHandleSliderExtender ID="MultiHandleSliderExtenderMinMax" runat="server" Minimum="0" Maximum="10" TargetControlID="txtCurrentValue">
<MultiHandleSliderTargets>
<ajax:MultiHandleSliderTarget ControlID="txtMin" />
<ajax:MultiHandleSliderTarget ControlID="txtMax" />
</MultiHandleSliderTargets>
</ajax:MultiHandleSliderExtender>
</div>
</td>
<td>
<asp:TextBox ID="txtMax" size="6" style="text-align:right;" runat="server" AutoPostBack="true" value="" />
</td>
</tr>
</table>
</td>
</tr>
underlying code:
public partial class IntervalSlider : System.Web.UI.UserControl, IRange
{
protected void Page_Load(object sender, EventArgs e)
{
lblHeader.Text = HttpUtility.HtmlEncode(HeaderText);
if ((ToolTipText ?? "") != "")
{
infoImg.Visible = true;
infoImg.ToolTip = ToolTipText;
lblHeader.ToolTip = ToolTipText;
}
divSlider.Attributes.Add("title", ToolTipText);
txtMax.ToolTip = ToolTipText;
txtMin.ToolTip = ToolTipText;
foreach (AjaxControlToolkit.MultiHandleSliderTarget target in MultiHandleSliderExtenderMinMax.MultiHandleSliderTargets)
target.ControlID = MultiHandleSliderExtenderMinMax.Parent.FindControl(target.ControlID).ClientID;
}
public string HeaderText { get; set; }
public string ToolTipText { get; set; }
protected void txtCurrentValue_TextChanged(object sender, EventArgs e)
{
//FilterChanged(sender, e);
}
public event EventHandler FilterChanged;
public string MaxFilterValue
{
get { return txtMax.Text; }
}
public int Minimum
{
get { return MultiHandleSliderExtenderMinMax.Minimum; }
set
{
MultiHandleSliderExtenderMinMax.Minimum = value;
txtMin.Text = value.ToString();
}
}
public int Maximum
{
get { return MultiHandleSliderExtenderMinMax.Maximum; }
set {
int minValue = value;
MultiHandleSliderExtenderMinMax.Maximum = minValue;
txtMax.Text = minValue.ToString();
}
}
public string MinFilterValue
{
get { return txtMin.Text; }
}
}
}
Anyone have a clue on how to solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 IntervalSelector 的页面加载末尾使用这段 JavaScript 代码解决了这个问题:
I solved it with this bit of JavaScript-code at the end of the Page Load of the IntervalSelector: