Thursday, 7 August 2014

Using MultiHandleSliderExtender in Asp.Net

Here, I am explain How to use MultiHandleSliderExtender  in Asp.Net

DESIGNER SOURCE CODE :


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="slider.aspx.cs" Inherits="slider" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Using MultiHandleSliderExtender Ajax Toolkit</title>

   


</head>
<body>
    <form id="form1" runat="server">
    <div runat="server">
    <script type="text/javascript">


        function ValueChangedHandler(sender, args) {
            $get("HiddenField1").value = $get("txtLeftHandle").value;
            $get("HiddenField2").value = $get("txtRightHandle").value;
            __doPostBack("<%=Button1.UniqueID %>", "");
        }
   

    </script>
    </div>
    <div>
       
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:TextBox ID="txtSlider" runat="server"></asp:TextBox>
        <asp:MultiHandleSliderExtender ID="MultiHandleSliderExtender1" BehaviorID="mhSlider"
            runat="server" TargetControlID="txtSlider" Length="257" ShowInnerRail="true"
            ShowHandleHoverStyle="true" OnClientDragEnd="ValueChangedHandler">
            <MultiHandleSliderTargets>
                <asp:MultiHandleSliderTarget ControlID="txtLeftHandle" />
                <asp:MultiHandleSliderTarget ControlID="txtRightHandle" />
            </MultiHandleSliderTargets>
        </asp:MultiHandleSliderExtender>
        <br />
        <table>
            <tr>
                <td align="left">
                    MININUM VALUE :
                    <asp:TextBox ID="txtLeftHandle" runat="server" Width="30" Text="0"></asp:TextBox>
                    <asp:HiddenField ID="HiddenField1" runat="server" />
                </td>
                <td align="right">
                    MAXIMUM VALUE:
                    <asp:TextBox ID="txtRightHandle" runat="server" Width="30" Text="100"></asp:TextBox>
                    <asp:HiddenField ID="HiddenField2" runat="server" />
                </td>
            </tr>
        </table>
        <asp:Button ID="Button1" runat="server" Text="Button" Style="display: none" OnClick="Buttonclick"/>
        <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
    </div>
    </form>
</body>
</html>



CODE BEHIND :



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class slider : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Buttonclick(object sender, EventArgs e)
    {
        Label1.Text = "Left value is " + HiddenField1.Value + "; Right value is " + HiddenField2.Value;
    }
}

No comments:

Post a Comment