首页 > 代码库 > asp.net--slider控件
asp.net--slider控件
.aspx代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="slider_综合实例.aspx.cs" Inherits="lesson_code_Default2" %>
<!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></title>
<style type ="text/css">
#div_nav{ width:200px;}
#div_content { width:500px;
margin-left:20px;
padding:10px; }
.myHandle { width:10px; height:10px;
margin-top:10px; }
.myRail { width:500px; height:10px;
background-image:url("../img/rail_pm.png"); background-repeat:no-repeat;
position:relative; }
</style>
<link href=http://www.mamicode.com/"../CSS/CSS_DEFAULT.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="div_nav" class ="fl">
<asp:TreeView ID="tv_date" runat="server"
onselectednodechanged="tv_date_SelectedNodeChanged" ShowCheckBoxes="All">
</asp:TreeView>
<asp:Button ID="btn_showList" runat="server" Text="Button"
onclick="btn_showList_Click" />
</div>
<myatk:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</myatk:ToolkitScriptManager>
<div id="div_content" class ="fl">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:ListView ID="ListView1" runat="server" DataSourceID="AccessDataSource1"
ItemPlaceholderID="itemHolder">
<LayoutTemplate>
<div id="itemHolder" runat="server"></div>
</LayoutTemplate>
<ItemTemplate>
<h3> <%#Eval("pm_date","{0:D}") %></h3>
<asp:TextBox ID="txt_pm25" runat="server"
Text=‘<%#Eval("pm_val") %>‘/>
<myatk:SliderExtender ID="TextBox1_SliderExtender" runat="server"
Enabled="True" Maximum="500" Minimum="0" TargetControlID="txt_pm25"
HandleCssClass="myHandle" HandleImageUrl="~/IMG/handle_pm.png"
RailCssClass="myRail">
</myatk:SliderExtender>
</ItemTemplate>
</asp:ListView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/DATA/pm25.mdb"
SelectCommand="SELECT * FROM [T_PM25] WHERE ([pm_id] = ?)">
<SelectParameters>
<asp:ControlParameter ControlID="tv_date" DefaultValue=http://www.mamicode.com/"1" Name="pm_id"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:AccessDataSource>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID ="btn_showList" />
</Triggers>
</asp:UpdatePanel>
</div>
<div class ="clr"></div>
</div>
</form>
</body>
</html>
.aspx.cs代码如下:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.OleDb; public partial class lesson_code_Default2 : System.Web.UI.Page { string str_cnn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="; string str_sourcefile = "~/data/pm25.mdb"; OleDbConnection cnn; OleDbCommand cmd; OleDbDataReader datar; string str_sql; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { maketree(); } } protected void maketree() { string str_conn = str_cnn + MapPath(str_sourcefile); cnn = new OleDbConnection(str_conn); cnn.Open(); str_sql = "SELECT * FROM T_PM25"; cmd = new OleDbCommand(str_sql, cnn); datar = cmd.ExecuteReader(); TreeNode _tnode; while (datar.Read()) { _tnode = new TreeNode(); _tnode.Text = string.Format("{0:D}", (DateTime)datar["pm_date"]); _tnode.Value = http://www.mamicode.com/datar["pm_id"].ToString();>
效果如下:
asp.net--slider控件