Source Code

for file /controls/HSlider.ascx

<%@ Control Language="C#" Inherits="AJAXControls.BaseControl" %>
<%
  // HSlider.ascx
  // Implementation of the HSlider AJAX Control.
  // Copyright (c) by Matthias Hertel, http://www.mathertel.de
  // This work is licensed under a BSD style license. See http://www.mathertel.de/License.aspx
  // ----- 
  // 17.09.2005 created by Matthias Hertel
  // 05.02.2006 multiple JavaScript Behaviours include bug fixed.
  // 05.08.2006 advanced layout, increment decrement buttons added.
  // 05.08.2006 width, minvalue, maxvalue, unit attributes added.
  // 29.06.2007 layout pixel bugs resolved.
  // 26.10.2007 inheriting from BaseControl
  // 06.01.2008 documentation and simplifications
  // 14.09.2008 fixed positioning
%>
<script runat="server">
  public bool _nosubmit = true;
  private string _eventname = String.Empty; // the name of the data-connection

  public int _width = 200;

  public int _minvalue = 0;
  public int _maxvalue = 100;
  public int _unit = 1;

  public string eventname
  {
    get { return _eventname; }
    set { _eventname = value; }
  } // eventname

  public int minvalue
  {
    get { return _minvalue; }
    set { _minvalue = value; }
  } // _minvalue

  public int maxvalue {
    get { return _maxvalue; }
    set { _maxvalue = value; }
  } // _maxvalue

  public int unit {
    get { return _unit; }
    set { _unit = value; }
  } // _unit

  public bool nosubmit {
    get { return _nosubmit; }
    set { _nosubmit = value; }
  } // nosubmit


  public int width {
    get { return _width; }
    set { _width = value; }
  } // width

  protected override void OnPreRender(EventArgs e) {
    base.OnPreRender(e);
    base.RegisterBehavior("hslider");
  } // OnPreRender
</script>
<!-- Here comes the HTML code that builds the Control. -->
<div class="HSlider" id="<%=this.ClientID %>" style="font-size:0px;float:left;height:16px;
  padding-top: 3px;" padding-bottom: 3px;" eventname="<%=this._eventname %>" minvalue="<%=this._minvalue.ToString() %>" maxvalue="<%=this._maxvalue.ToString() %>"
  unit="<%=this._unit.ToString() %>">
  <img alt="decrement" class="minus" src="/controls/images/sliderMinus.gif" style="float:left" />
  <div style="position:relative;float:left">
    <img alt="move me" class="knob" src="/controls/images/sliderButton.gif" style="position: absolute; left: 0px" />
    <img alt="slider" class="slider" style="width: <%=this.width-32%>px; height: 16px" src="/controls/images/sliderBack.gif" />
  </div>
  <img alt="increment" class="plus" src="/controls/images/sliderPlus.gif" style="float:left" /></div>
<!-- Here comes the script code to bind the behaviour. -->
<script defer="defer" type="text/javascript">
  jcl.LoadBehaviour("<%=this.ClientID %>", jcl.HSliderBehavior);
</script>


This page is part of the http://www.mathertel.de/ web site.

For updates and discussions see http://ajaxaspects.blogspot.com/.