Guys!
I got 2 ajaxToolkit:sliderExtenders
"SliderExtenderVertical" and "SliderHorizontal" targeting 2 asp:TextBoxes
"SliderVertical" (with definition for "SliderVertical_TextChanged") and "SliderHorizontal" (with definition for "SliderHorizontal_TextChanged") respectively.
However, when "SliderVertical" is slided, both "SliderVertical_TextChanged" and "SliderHorizontal_TextChanged" events are triggered!
How to prevent "SliderHorizontal_TextChanged" event from being fired when "SliderVertical" is slided?
As a matter of fact, when I slide the "SliderHorizontal" only "SliderHorizontal_TextChanged" event is triggered!
Please help.
Thanks.
Code Snippet:
// WebForm1.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void SliderVertical_TextChanged(object sender, EventArgs e)
{
TextBox1.Text = string.Empty;
TextBox1.Text = "Vertical!";
}
protected void SliderHorizontal_TextChanged(object sender, EventArgs e)
{
TextBox2.Text = string.Empty;
TextBox2.Text = "Horizontal!";
}
}
// WebForm1.aspx.cs
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebForm1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<link href="css/slider.css" type="text/css" rel="stylesheet" id="Link1" />
</head>
<body>
<form id="form1" runat="server">
<html
<ajaxToolkit:ToolkitScriptManager id="ScriptManager1" runat="server" />
<table >
<tr>
<td>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="SliderVertical" runat="server" AutoPostBack="true"
Text="0" ontextchanged="SliderVertical_TextChanged" ValidationGroup="1" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<ajaxToolkit:SliderExtender ID="SliderExtenderVertical" runat="server"
TargetControlID="SliderVertical"
Orientation="Vertical"
EnableHandleAnimation="true"
/>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" >
<ContentTemplate>
<asp:TextBox ID="SliderHorizontal" runat="server" AutoPostBack="true"
Text="0" ontextchanged="SliderHorizontal_TextChanged" ValidationGroup="2" />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<ajaxToolkit:SliderExtender ID="SliderExtenderHorizontal" runat="server"
TargetControlID="SliderHorizontal"
Orientation="Horizontal"
EnableHandleAnimation="true"
Minimum="-50"
Maximum="50"
Steps="5"
Decimals="2" />
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
</form>
</body>
</html>