当前位置:  编程技术>.net/c#/asp.net
本页文章导读:
    ▪Gridview使用CheckBox全选与单选      Insus.NET对Gridview使用CheckBox单选与全选功能再次进行简单演示,选中的行,使用高亮显示,让用户一目了然看到哪一行被选择了。本例中,使用前端脚本Javascript来实现。还是先看看Insus.NET做出.........
    ▪给管道注册事件,用于用户是否登录!      1.一个网站项目的自定义cs文件,如图:2.CheckRight.cs中的代码如下:public class CheckRight : IHttpModule{ public void Dispose() { } public void Init(HttpApplication app) { app.AcquireRequestState += new EventH.........
    ▪读取XML并绑定至RadioButtonList      读取XML的文档,可以使用System.Data.DataSet类别中的ReadXml()方法。如下面的xml文档,放在站点的根目录之下:<?xml version="1.0" encoding="utf-8" ?><YearOfBirths> <YearOfBirth> <ID>1</ID> .........

[1]Gridview使用CheckBox全选与单选
    来源:    发布时间: 2013-10-28

Insus.NET对Gridview使用CheckBox单选与全选功能再次进行简单演示,选中的行,使用高亮显示,让用户一目了然看到哪一行被选择了。本例中,使用前端脚本Javascript来实现。还是先看看Insus.NET做出来的效果:

 

Insus.NET原本是从数据库获取数据并绑定至GridView控件的,为了在学asp.net的网友,也能轻易操作,因此这个想法,采用对象存储数据。

首先创建一个对象,[对联]的对象:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for Couplets
/// </summary>
namespace Insus.NET
{
public class Couplets
{
private int _ID;
private string _Type;
private string _Content;

public int ID
{
get { return _ID; }
set { _ID = value; }
}
public string Type
{
get { return _Type; }
set { _Type = value; }
}
public string Content
{
get { return _Content; }
set { _Content = value; }
}

public Couplets()
{
//
// TODO: Add constructor logic here
//
}

public Couplets(int id, string type, string content)
{
this._ID = id;
this._Type = type;
this._Content = content;
}
}
}

 

对象准备好,它是的空的对象,所以还得为刚才创建好的对象,填充数据,让它成为真正的实体。

public List<Couplets> GetData()
{
List<Couplets> couplets = new List<Couplets>();

Couplets c = new Couplets(1, "四字联", "一元复始;万象更新。");
couplets.Add(c);

c = new Couplets(2, "四字联", "风调雨顺;国盛人和。");
couplets.Add(c);

c = new Couplets(3, "四字联", "风调雨顺;国盛人和。");
couplets.Add(c);
c = new Couplets(4, "五字联", "金蛇含瑞草;紫燕报新春。");
couplets.Add(c);

c = new Couplets(5, "五字联", "龙年留胜绩;蛇岁展宏猷。");
couplets.Add(c);

c = new Couplets(6, "七字联", "壬辰传捷龙辞旧;癸巳报春蛇迎新。");
couplets.Add(c);

c = new Couplets(7, "七字联", "山高水远人增志;蛇接龙年地满春。");
couplets.Add(c);

c = new Couplets(8, "七字联", "小龙起舞神州地;祖国腾飞大治年。");
couplets.Add(c);

c = new Couplets(9, "七字联", "金山水漫双蛇舞;绿野春归百鸟鸣。");
couplets.Add(c);

return couplets;
}


在Default.aspx网页上拉一个GridView控件。

<
    
[2]给管道注册事件,用于用户是否登录!
    来源:    发布时间: 2013-10-28

1.一个网站项目的自定义cs文件,如图:

2.CheckRight.cs中的代码如下:

public class CheckRight : IHttpModule
{

public void Dispose()
{
}

public void Init(HttpApplication app)
{
app.AcquireRequestState += new EventHandler(app_AcquireRequestState);//nine event
// app.BeginRequest += new EventHandler(app_BeginRequest);

void app_AcquireRequestState(object sender, EventArgs e)
{
HttpApplication app = sender as HttpApplication;
if (app.Request.RawUrl.Contains(".aspx"))
{
if (app.Session["user"] == null)
{
app.Response.Write("<script>alert('请先登录');window.location.href='/Login.htm'</script>");

//window.location.href='/Login.htm'为当前页赋值为'../Login.htm',使当前页面跳转到Login.htm页面。
}
}

}
}

3.web.Config配置一下:

在<system.web>节点下,配置如下:
<httpModules>
<add name="cccccccc" type="CheckRight"/>
</httpModules>

其中:name可以任意起,但是type为CheckRight.cs文件中class 的名字,如果有命名空间的话,要在类之前加上命名空间的名字!

本文链接


    
[3]读取XML并绑定至RadioButtonList
    来源:    发布时间: 2013-10-28

读取XML的文档,可以使用System.Data.DataSet类别中的ReadXml()方法。如下面的xml文档,放在站点的根目录之下:

<?xml version="1.0" encoding="utf-8" ?>
<YearOfBirths>
<YearOfBirth>
<ID>1</ID>
<Name>鼠</Name>
</YearOfBirth>
<YearOfBirth>
<ID>2</ID>
<Name>牛</Name>
</YearOfBirth>
<YearOfBirth>
<ID>3</ID>
<Name>虎</Name>
</YearOfBirth>
<YearOfBirth>
<ID>4</ID>
<Name>兔</Name>
</YearOfBirth>
<YearOfBirth>
<ID>5</ID>
<Name>龙</Name>
</YearOfBirth>
<YearOfBirth>
<ID>6</ID>
<Name>蛇</Name>
</YearOfBirth>
<YearOfBirth>
<ID>7</ID>
<Name>马</Name>
</YearOfBirth>
<YearOfBirth>
<ID>8</ID>
<Name>羊</Name>
</YearOfBirth>
<YearOfBirth>
<ID>9</ID>
<Name>猴</Name>
</YearOfBirth>
<YearOfBirth>
<ID>10</ID>
<Name>鸡</Name>
</YearOfBirth>
<YearOfBirth>
<ID>11</ID>
<Name>狗</Name>
</YearOfBirth>
<YearOfBirth>
<ID>12</ID>
<Name>猪</Name>

    
最新技术文章:
 




特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3