1 using System;
2 using System.Collections.Generic;
3 using System.Collections.Specialized;
4 using System.Linq;
5 using System.Web;
6 using System.Text;
7 using System.Web.Mvc;
8 using System.Web.Routing;
9 using System.Data.Objects.DataClasses;
10 namespace System.Web.Mvc
11 {
12 public static class PagerHelper
13 {
14 /// <summary>
15 /// 分页
16 /// </summary>
17 /// <param name="helper"></param&g ......
分页代码如下(PageHelper.cs):
代码
1 using System;
2 using System.Collections.Generic;
3 using System.Collections.Specialized;
4 using System.Linq;
5 using System.Web;
6 using System.Text;
7 using System.Web.Mvc;
8 using System.Web.Routing;
9 using System.Data.Objects.DataClasses;
10 namespace System.Web.Mvc
11 {
12 public static class PagerHelper
13 {
14 /// <summary>
15 /// 分页
16 /// </summary>
17 / ......
今天,学习了ASP.NET中连接数据库的各种方法,这是我自己的一个小总结,不一定完全正确,仅供参考! O(∩_∩)O~
连接SQL数据库的方法:
(一)、在Web.Config中创建连接字符串:
1、
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\grade.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
2、
<add name="sampleConnectionString" connectionString ="server=.\SQLEXPRESS;database=sample;uid=sa;pwd=123456;" providerName ="System.Data.SqlClient"/>
3、
<add name ="testConnectionString" connectionString ="Data Source=.\SQLEXPRESS;Initial Catalog=sample;Integrated Security=True;Persist Security Info=True;User ID=sa;Password=123456" providerName ="System.Data.SqlClient"/>
(二)、在aspx.cs中获取连接字符串:
1、
string strCon = System.Configuration.ConfigurationManager.ConnectionStrings["sampleConnectionString"].ConnectionString;
2、
string strCon = System.C ......
第一, 新建网站,选择类型为asp.net web 服务。
系统自动为你建立了个文件service.asmx.这就是一个最简单的web service服务。你可以直接运行查看效果。
第二,我们需要的是修改service.cs中的代码,来满足我们的要求。
修改后的Service.cs中的代码为:
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[WebService(Namespace = "http://127.0.0.1/")] //调用此web service的地址
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
//[WebMethod]
//public string HelloWorld() {
// return "Hello World";
//}
/// <summary>
// ......
介绍
缓存是在内存存储数据的一项技术,也是ASP.NET中提供的重要特性之一。例如你可以在复杂查询的时候缓存数据,这样后来的请求就不需要从数据库中取数据,而是直接从缓存中获取。通过使用缓存可以提高应用程序的性能。
主要有两种类型的缓存:
1.输出缓存Output caching
2.数据缓存Data caching
1. 输出缓存(Output Caching)
使用输出缓存,你可以缓存最后输出的HTML页面,当相同的页面再次请求的时候,ASP.NET不会再执行页面的生命周期和相关代码而是直接使用缓存的页面,语法如下:
<%@ OutputCache Duration=”60” VaryByParam=”None” %>
Duration 属性设置页面将被缓存60妙。任何的用户请求都会被缓存,在缓冲的60秒内相同的请求都会直接使用缓存的页面。当缓存过期后ASP.NET会再次执行页面代码并且为下一个60秒创建一个新的HTML缓存。
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="OutputCachingTest.aspx.cs" Inherits="OutputCachingTest ......
一.后台调用前台
1.Page.ClientScript.RegisterStartupScript(type,"",script);
例:
string script = string.Format("<script>alert('Wrong');</script>");
Page.ClientScript.RegisterStartupScript(GetType(), "Load", script);
2.对象.Attributes.Add("事件","script")
例:
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#ECECFF'");
二.前台调用后台
1.一般没有必要在html文件里调用cs文件.
......