asp.net 常用知識點彙總整理
1、後臺動態建立DataTable,並繫結Repeater
DataTable dtNew = new DataTable();
dtNew.Columns.Add("Name", typeof(string));
dtNew.Columns["Name"].SetOrdinal(0);
dtNew.Columns.Add("CNT", typeof(string));
dtNew.Columns["CNT"].SetOrdinal(1);
dtNew.Columns.Add("SUMValue", typeof(double));
dtNew.Columns["SUMValue"].SetOrdinal(2);
//1、
DataRow dr1 = dtNew.NewRow();
dr1["Name"] = "鍋爐";
dr1["CNT"] = "221";
dr1["SUMValue"] = 2748199.2;
dtNew.Rows.Add(dr1);
//2、
DataRow dr2 = dtNew.NewRow();
dr2["Name"] = "變壓器";
dr2["CNT"] = "210";
dr2["SUMValue"] = 2424021;
dtNew.Rows.Add(dr2);
//3、
DataRow dr3 = dtNew.NewRow();
dr3["Name"] = "電動機";
dr3["CNT"] = "200";
dr3["SUMValue"] = 2424021;
dtNew.Rows.Add(dr3);
//4、
DataRow dr4 = dtNew.NewRow();
dr4["Name"] = "水泵";
dr4["CNT"] = "150";
dr4["SUMValue"] = 1424021;
dtNew.Rows.Add(dr4);
//5、
DataRow dr5 = dtNew.NewRow();
dr5["Name"] = "風機";
dr5["CNT"] = "90";
dr5["SUMValue"] = 81123;
dtNew.Rows.Add(dr5);
//6、
DataRow dr6 = dtNew.NewRow();
dr6["Name"] = "製冷機";
dr6["CNT"] = "100";
dr6["SUMValue"] = 81123;
dtNew.Rows.Add(dr6);
//7、
DataRow dr7 = dtNew.NewRow();
dr7["Name"] = "其它";
dr7["CNT"] = "100";
dr7["SUMValue"] = 81123;
dtNew.Rows.Add(dr7);
rptDevice.DataSource = dtNew;
rptDevice.DataBind();
2、HighCharts多座標圖表顯示
$(function () {
$('#container').highcharts({
chart: {
zoomType: 'xy'
},
title: {
text: 'Average Monthly Weather Data for Tokyo'
},
subtitle: {
text: 'Source: WorldClimate.com'
},
xAxis: [{
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
}],
yAxis: [{ // Primary yAxis
labels: {
formatter: function() {
return this.value +'°C';
},
style: {
color: '#89A54E'
}
},
title: {
text: 'Temperature',
style: {
color: '#89A54E'
}
},
opposite: true
}, { // Secondary yAxis
gridLineWidth: 0,
title: {
text: 'Rainfall',
style: {
color: '#4572A7'
}
},
labels: {
formatter: function() {
return this.value +' mm';
},
style: {
color: '#4572A7'
}
}
}, { // Tertiary yAxis
gridLineWidth: 0,
title: {
text: 'Sea-Level Pressure',
style: {
color: '#AA4643'
}
},
labels: {
formatter: function() {
return this.value +' mb';
},
style: {
color: '#AA4643'
}
},
opposite: true
}],
tooltip: {
shared: true
},
legend: {
layout: 'vertical',
align: 'left',
x: 120,
verticalAlign: 'top',
y: 80,
floating: true,
backgroundColor: '#FFFFFF'
},
series: [{
name: 'Rainfall',
color: '#4572A7',
type: 'column',
yAxis: 1,
data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
tooltip: {
valueSuffix: ' mm'
}
}, {
name: 'Sea-Level Pressure',
type: 'spline',
color: '#AA4643',
yAxis: 2,
data: [1016, 1016, 1015.9, 1015.5, 1012.3, 1009.5, 1009.6, 1010.2, 1013.1, 1016.9, 1018.2, 1016.7],
marker: {
enabled: false
},
dashStyle: 'shortdot',
tooltip: {
valueSuffix: ' mb'
}
}, {
name: 'Temperature',
color: '#89A54E',
type: 'spline',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6],
tooltip: {
valueSuffix: ' °C'
}
}]
});
});
3、系統超時或者Session丟失,自動跳轉到登入頁面
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;
namespace SYIT
{
public class FilterModule : IHttpModule, IRequiresSessionState
{
public void Dispose()
{
// throw new NotImplementedException();
}
public void Init(HttpApplication context)
{
//原因:這個事件時,Session尚未建立。要先指定型別在判斷位址列是否存在
//context.BeginRequest += new EventHandler(context_BeginRequest);
context.AcquireRequestState += (obj, e) =>
{
var app = (HttpApplication)obj;
var url = app.Request.RawUrl;
//還要先判斷下請求型別
if (url.IndexOf(".aspx") > 0)
{
//判斷非UserLogin請求防止進入死迴圈(此網頁包含重定向迴圈)
if (url.IndexOf("Login.aspx") < 0)
{
if (app.Context.Session["user"] == null)
{
//app.Context.Response.Redirect("~/Login.aspx", false);
string loginURl = "";
string virPath = app.Request.ApplicationPath;
if (string.IsNullOrEmpty(virPath) || virPath == "/")
{
loginURl = string.Format("{0}://{1}:{2}/Login.aspx", app.Request.Url.Scheme, app.Request.Url.Host, app.Request.Url.Port);
}
else
{
loginURl = string.Format("{0}://{1}:{2}{3}/Login.aspx", app.Request.Url.Scheme, app.Request.Url.Host, app.Request.Url.Port, virPath);
}
app.Context.Response.Write("<script>alert('您尚未登入或者賬戶資訊已過期,請重新登入!');top.location='" + loginURl + "' ;</script>");
app.Context.Response.End();
}
}
}
};
}
}
}
<system.web>
<httpModules>
<!--重寫IHttpModule類,需要配置的資訊-->
<add name="filterModule" type="SYIT.FilterModule" />
</httpModules>
</system.web>
4、
相關文章
- Flow 常用知識點整理
- js知識點彙總JS
- SVM知識點彙總
- JavaScript知識點彙總JavaScript
- java知識點彙總Java
- Koa 框架常用知識點整理框架
- ES6 常用知識彙總
- iOS 知識-常用小技巧彙總iOS
- 前端小知識點彙總前端
- MySQL MVCC知識點彙總MySqlMVC
- 藍橋杯知識點彙總:基礎知識和常用演算法演算法
- C++知識點大彙總C++
- java異常知識點彙總Java
- MySQL基礎知識點彙總MySql
- ASP.NET MVC5 知識點整理ASP.NETMVC
- RabbitMQ 常用知識點總結MQ
- docker常用知識點總結Docker
- mysql 常用知識點總結MySql
- Java常見知識點彙總(⑳)——鎖Java
- Java常見知識點彙總(②)——StaticJava
- Python入門知識點彙總Python
- C/C++重要知識點彙總C++
- 彙編必知小知識點及常用debug命令
- MySQL知識彙總MySql
- Docker 知識彙總Docker
- 前端知識彙總前端
- Java常見知識點彙總(⑦)——集合框架Java框架
- Java常見知識點彙總(⑨)——異常Java
- Java常見知識點彙總(⑪)——泛型Java泛型
- Pandas知識點彙總(2)——布林索引索引
- PHP入門易忘知識點彙總PHP
- 玩轉javaScript---知識點彙總(3)JavaScript
- 玩轉javascript---知識點彙總(2)JavaScript
- 玩轉javascript---知識點彙總(1)JavaScript
- MySQL 常用易混淆知識點總結MySql
- JavaScript知識點整理JavaScript
- CSS知識點整理CSS
- CANFD知識點整理