用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下载——word,txt,图片方法
本文主要介绍ASP.NET下载诸如word,txt,图片等的方法。
try
{
FullFileName = Server.MapPath(FileName); //FileName--要下载的文件名
FileInfo DownloadFile= new FileInfo(FullFileName);
if(Down ......
在你的Page_Load中添加这样的代码:
Page.Response.Clear();
bool success = ResponseFile(Page.Request, Page.Response, "目的文件名称", @"源文件路径", 1024000);
if (!success)
Response.Write("下载文件出错!");
Page. ......
//TransmitFile实现下载
protected void Button1_Click(object sender, EventArgs e)
{
/*
......
1、DateTime 数字型
System.DateTime currentTime=new System.DateTime();
1.1 取当前年月日时分秒
currentTime=System.DateTime.Now;
1.2 取当前年
&nb ......
正常操作情况下会有ASP.NET Session丢失的情况出现。因为程序是在不停的被操作,排除Session超时的可能。另外,Session超时时间被设定成60分钟,不会这么快就超时的。
现在我就把原因和解决办法写出来。
ASP.NET Session丢失原因:
由于Asp.net程序是默认配置,所以Web.Config文件中关于Session的设定如下:
< sessi ......