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

推荐订阅源

S
Security @ Cisco Blogs
H
Hacker News: Front Page
P
Privacy International News Feed
N
News and Events Feed by Topic
T
Threatpost
Simon Willison's Weblog
Simon Willison's Weblog
S
Schneier on Security
K
Kaspersky official blog
S
Secure Thoughts
V2EX - 技术
V2EX - 技术
Security Latest
Security Latest
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
CERT Recently Published Vulnerability Notes
L
Lohrmann on Cybersecurity
Jina AI
Jina AI
P
Proofpoint News Feed
AI
AI
雷峰网
雷峰网
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园 - 叶小钗
Webroot Blog
Webroot Blog
Apple Machine Learning Research
Apple Machine Learning Research
SecWiki News
SecWiki News
罗磊的独立博客
N
Netflix TechBlog - Medium
Martin Fowler
Martin Fowler
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
S
Security Affairs
Blog — PlanetScale
Blog — PlanetScale
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
月光博客
月光博客
D
Docker
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Securelist
W
WeLiveSecurity
T
Troy Hunt's Blog
A
Arctic Wolf
博客园 - 司徒正美

博客园 - 深瞳

懒惰化、标准化、自动化——工具化--利用合适的工具构建流水线软件过程 脚本语言的游戏开发 准妈妈必听的十首乐曲完全版 [原创]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: