Alan Cai's Blogs
只埋头苦干是不行的,有时候还得抬头看看外面的世界。

随笔分类 -  ASP.NET

ASP.NET MVC自定义异常捕捉及处理
摘要:在日常开发中,经常会使用自定义异常传递业务逻辑验证消息,在ASP.NET MVC可采用重载 Controller 的OnException 方法进行自定义异常的捕捉。自定义异常类,用于承载业务逻辑验证信息,如下列代码所示:1 using System;2 3 namespace Web4 {5 public class CustomException : ApplicationException6 {7 public CustomException(string message) : base(message) { }8 }9 }自定义 ASP.NET ... 阅读全文
posted @ 2013-06-05 18:20 Alan Cai 阅读(2587) 评论(0) 推荐(0)
自定义应用程序配置节点
摘要:在开发中,相信大家经常都要和配置文件打交道,不管是应用程序的App.config文件,或者是Web程序的Web.config文件。今天闲来无事,突然想到一直只是在用*.config文件进行配置参数,却从未做过自定义配置节点的开发,稍微研究了一下,写下此文记录学习心得。先介绍一下本文中涉及到的配置文件分别为 App.config 和 Collector.config。App.config 1 <?xml version="1.0" encoding="utf-8" ?> 2 <configuration> 3 <configS 阅读全文
posted @ 2013-06-04 17:51 Alan Cai 阅读(842) 评论(0) 推荐(0)
ASP.NET 配置文件 configSource 的用法
摘要:在站点的默认 Web.Config 文件中使用:<appSettings configSource="My.config"/>然后新建 My.Config 文件:<?xml version="1.0" encoding="utf-8"?><appSettings> <add key="test" value="Hello world."/><... 阅读全文
posted @ 2008-09-12 10:14 Alan Cai 阅读(1133) 评论(1) 推荐(0)
查找当前页面或窗口中某类型控件并赋值
摘要:WinFormforeach (Control control in this.Controls) { if (control is TextBox) { (control as TextBox).Text = "Hello World."; }}ASP.NETforeach (Control control in this.FindControl("form1").Controls) { if ... 阅读全文
posted @ 2008-09-11 10:24 Alan Cai 阅读(494) 评论(0) 推荐(0)
ASP.NET 访问 Web Service 服务器 Session
摘要:1、在 Web Service 里添加 Session[WebMethod(EnableSession = true)]public void CreateSession() { Session["Ikesy"] = "Hello world.";}ASP.NET 页面使用SessionService.SessionService sessionService = new SessionServi... 阅读全文
posted @ 2008-09-10 18:24 Alan Cai 阅读(773) 评论(1) 推荐(0)