用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
相关文档:
使用asp.net 开发wap 网站,在ishtml32下,如果手机浏览器支持ishtml32,但是 SupportsCss=False 时,想加载css文件时,采用重写mobile:form的方法来实现
using System;
using System.Configuration;
using System.Web.UI.MobileControls;
using System.Web.UI.MobileControls.Adapters;
public class MyForm : Form
{ ......
1、DateTime 数字型
System.DateTime currentTime=new System.DateTime();
1.1 取当前年月日时分秒
currentTime=System.DateTime.Now;
1.2 取当前年
&nb ......
ASP.NET提供了Session对象,从而允许程序员识别、存储和处理同一个浏览器对象对服务器上某个特定网络应用程序的若干次请求的上下文信息。Session对应浏览器与服务器的同一次对话,在浏览器第一请求网络应用程序的某个页面时,服务器会触发Session_onStart事件;在对话超时或者被关闭的时候会触发Session_onEnd 事件。程序员 ......
@Page指令位于每个ASP.NET页面的顶部,告诉ASP.NET这个具体页面使用什么属性,以及该页面继承的用户控件。ASP.NET页面
@Page指令属性有:AspCompat、Async、AsyncTimeout、AutoEventWireup、Buffer、
ClassName、ClientIDMode、CodeBehind、
CodeFile、CodeFileBaseClass、CodePage、CompilationMode 、ContentType、
......
//ASP.NET获取中文首字母
public class Converter
{
static public string GetChineseSpell(string strText)
{
......