惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Schneier on Security
Schneier on Security
N
Netflix TechBlog - Medium
IT之家
IT之家
MongoDB | Blog
MongoDB | Blog
博客园_首页
S
SegmentFault 最新的问题
H
Help Net Security
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
T
The Blog of Author Tim Ferriss
量子位
GbyAI
GbyAI
M
MIT News - Artificial intelligence
Recorded Future
Recorded Future
P
Privacy & Cybersecurity Law Blog
B
Blog
月光博客
月光博客
博客园 - 聂微东
Vercel News
Vercel News
罗磊的独立博客
腾讯CDC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
A
Arctic Wolf
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
Blog — PlanetScale
Blog — PlanetScale
L
Lohrmann on Cybersecurity
I
Intezer
小众软件
小众软件
T
The Exploit Database - CXSecurity.com
Jina AI
Jina AI
C
Check Point Blog
AWS News Blog
AWS News Blog
C
Cisco Blogs
Martin Fowler
Martin Fowler
The Last Watchdog
The Last Watchdog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
宝玉的分享
宝玉的分享
S
Security Affairs
大猫的无限游戏
大猫的无限游戏
N
News and Events Feed by Topic
雷峰网
雷峰网
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
H
Hacker News: Front Page
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
F
Full Disclosure
P
Proofpoint News Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Security Blog
Microsoft Security Blog

博客园 - 深瞳

懒惰化、标准化、自动化——工具化--利用合适的工具构建流水线软件过程 脚本语言的游戏开发 准妈妈必听的十首乐曲完全版 [原创]Flex和PHP脚本的整合(2)--AMFPHP篇 [原创]Flex和PHP脚本的整合(1)--XML篇 夜如深瞳,瞳深如夜 新一波VB.NET升级需求涌现 使用VS2005的WEB部署工程 VS2005web应用程序项目教程(7)Upgrading VS 2003 Web Projects to be VS 2005 Web Application Projects VS2005web应用程序项目教程(6)Creating and Using User Control Libraries VS2005web应用程序项目教程(5)Using Master Pages and Site Navigation VS2005web应用程序项目教程(4)Data Binding against Objects VS2005web应用程序项目教程(2)Code-Behind with VS 2005 Web Application Projects VS2005web应用程序项目教程(1)Building Your First Web Application Project 在.net开发中几个重要的认识误区 CSVS 和CSSDK 的区别 ASP.net(1.1)原理学习笔记--第十一章 安全性Security ASP.net(1.1)原理学习笔记--第十章 状态管理State Management ASP.net(1.1)原理学习笔记--第九章 缓存Caching
VS2005web应用程序项目教程(3)Building Pages with VS 2005 Web Application Projects
深瞳 · 2006-01-31 · via 博客园 - 深瞳

Tutorial 3: Building Pages with VS 2005 Web Application Projects

The below tutorial demonstrates how to build ASP.NET Pages within VS 2005 Web Application Projects. Please make sure that you have already completed Tutorial 2: Understanding Code-Behind with VS 2005 Web Application Projects before reviewing this one.

Coding against controls in our Default.aspx page

In the first Hello World Tutorial we edited the Default.aspx page that is added automatically when we create a new VS 2005 Web Application project.

Specifically we added an <asp:calendar> and <asp:label> control to the page:

We will want to be able to program against both of these controls within our code-behind file.

Visual Studio 2005 Web Application Project Preview-Only Note

Automatic generation of the code-behind control field declarations into the appropriate .designer.cs file is not yet implemented with this first preview release (this is a tempoary issue -- it will be implemented in the next refresh download).

To manually add the control declarations for the Calendar and Label controls to our Default.aspx.designer.cs file, open the file using the solution explorer and add the appropriate protected control declarations to the partial class:

You can then program against these controls using your event-handlers within the code-behind file. For example:

You can then set a breakpoint (press the F9 key on the line to set it on), and then hit F5 to compile, run and debug the page:

Handling server events from controls in our .aspx page

To handle a server event from a control on your page, you can either manually add an event-handler to the control yourself (by overridng the OnInit method in your code-behind class and adding the event delegate there), or by using the WYSIWYG designer to generate an event handler.

To use the WYSIWYG designer, click on the "design" tab of the .aspx page to bring up the design-surface.  If you want to add the "default" event for the control, you can simply double-click on the control to generate an event handler for it (this is useful for things like buttons, etc).  Alternatively, you can select the control on the design-surface and click on the "events" tab of the property-grid.  This will then list the events that are available to handle:

You can double-click on any of the events to automatically add a default named event handler.  Alternatively, you can type the name of the event handler you wish to generate.

Visual Studio 2005 Web Application Project Preview-Only Note

In the current VS 2005 Web Application Project download, event handlers in C# get added to a <script runat="server"> block within the .aspx page when added through the WYSIWYG designer instead of to the code-behind file.

This will be corrected in a future refresh -- and the event-handlers will obviously be added to the Default.aspx.cs code-behind file instead.  In the mean-time, simply do a cut/paste of the generated event-handler from the .aspx file and into the code-behind file (the syntax for the event handler and the binding work the same).

You can then add whatever code you want within the code-behind file:

Press F5 (or Ctrl-F5) to build and run the project. Now, when a user selects a date in the calendar, the selected date will be output using the Label control: