用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
相关文档:
//default.aspx.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Runtime.InteropService ......
使用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
{ ......
ASP.NET提供了Session对象,从而允许程序员识别、存储和处理同一个浏览器对象对服务器上某个特定网络应用程序的若干次请求的上下文信息。Session对应浏览器与服务器的同一次对话,在浏览器第一请求网络应用程序的某个页面时,服务器会触发Session_onStart事件;在对话超时或者被关闭的时候会触发Session_onEnd 事件。程序员 ......
asp.net 获取客户端计算机名
1. 在ASP.NET中专用属性:
获取服务器电脑名:Page.Server.ManchineName
获取用户信息:Page.User
获取客户端电脑名:Page.Request.UserHostName
获取客户端电脑IP:Page.Request.UserHostAddress
2. 在网络编程中的通用方法:
获取当前电脑名:static System.Net.Dns.GetHostNam ......