📄 spinner.ascx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Controls_Spinner : System.Web.UI.UserControl
{
private int m_minValue;
private int m_maxValue = 100;
private int m_currentNumber = 0;
public int MinValue//设置为可读写属性
{
get//读属性
{
return m_minValue;
}
set//写属性
{
if (value >= this.MaxValue)
{
throw new Exception("MinValue must be less than MaxValue.");
}
else
{
m_minValue = value;
}
}
}
public int MaxValue
{
get
{
return m_maxValue;
}
set
{
if (value <= this.MinValue)
{
throw new
Exception("MaxValue must be greater than MinValue.");
}
else
{
m_maxValue = value;
}
}
}
public int CurrentNumber
{
get
{
return m_currentNumber;
}
}
protected void Page_Load(Object sender, EventArgs e)
{
if (IsPostBack)
{
m_currentNumber =
Int16.Parse(ViewState["currentNumber"].ToString());
}
else
{
m_currentNumber = this.MinValue;
}
DisplayNumber();
}
//自定义一个DisplayNumber(),用来获取当前图书价格
protected void DisplayNumber()
{
textNumber.Text = this.CurrentNumber.ToString();
ViewState["currentNumber"] = this.CurrentNumber.ToString();
}
protected void buttonUp_Click(Object sender, EventArgs e)
{
if (m_currentNumber == this.MaxValue)
{
m_currentNumber = this.MinValue;
}
else
{
m_currentNumber += 1;
}
DisplayNumber();//调用DisplayNumber方法
}
protected void buttonDown_Click(Object sender, EventArgs e)
{
if (m_currentNumber == this.MinValue)
{
m_currentNumber = this.MaxValue;
}
else
{
m_currentNumber -= 1;
}
DisplayNumber();//调用DisplayNumber方法
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -