用ASP.NET做简易计算器和九九乘法表
简易计算器
1.在页面上放入TextBox控件和dropdownlist控件以及Button控件,形成下图的外观.
2.在做好页面后双击Button控件(即"="),写入如下代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
double a = Convert.ToDouble(TextBox1.Text);//定义一个变量a,把TextBox1中的值赋给它
double b = Convert.ToDouble(TextBox2.Text);//定义一个变量b,把TextBox2中的值赋给它
/*定义的变量为浮点型*/
if(DropDownList1.SelectedValue == "+" )//获取选择的运算符,确定运算类型
{
TextBox3.Text = Convert.ToString(a + b);
}
else if (DropDownList1.SelectedValue == "-")
{
TextBox3.Text = Convert.ToString(a - b);
}
else if (DropDownList1.SelectedValue == "*")
{
TextBox3.Text = Convert.ToString(a * b);
}
else if (DropDownList1.SelectedValue == "/")
&nbs
相关文档:
http://zhanglei1286.blog.163.com/blog/static/1895797120091112113019600/
在后台代码里:
SQL 2000:
static string StrConn = "server=.;uid=sa;pwd=sa;database=MyCUDS";
SQL2005:
con = new SqlConnection(@"Server=.\SQLExpress;Database=db_CMS;Persist Security Info=True;User ID=sa;Password=Masslong");
......
1、DateTime 数字型
System.DateTime currentTime=new System.DateTime();
1.1 取当前年月日时分秒
currentTime=System.DateTime.Now;
1.2 取当前年
&nb ......
-----------------------------------------------------引言开始-----------------------------------------------------
事情的起因是站点出现未登陆的假象,点着点着就跳到登陆页或提示用户登陆。
因为很多页面都继承了一个PageBase类,这个类会判断用户是否登陆如果没有登陆就会 ......
//ASP.NET获取中文首字母
public class Converter
{
static public string GetChineseSpell(string strText)
{
......