To |
Do this |
---|---|
Modify the runtime behavior of an ASP.NET Web Form |
Add the @ Page directive to the page and set the desired attributes. |
Use classes by name without explicitly specifying their namespace |
In a Web Form, add the @ Import directive, with the namespace attribute specifying the namespace to import. In a C# .NET code-behind file, add the using statement with the desired namespace. |
Make a user control or custom server control available for use on a Web Form |
Drag and drop the user control from the Solution Explorer window onto the design surface of a Web Form. |
Enable output caching |
Add the @ OutputCache directive to the page, and set the desired attributes. |
Create a user control |
Right-click the project in Solution Explorer, select Add, and then select Add Web User Control. Add the desired controls to the user control, and write any code necessary, and then save the files and build the project. |
Write server-side functions in a Web Forms page |
Create a <script> block with the runat=“server” attribute and place the functions within it. |
Handle page-level events |
Add an event handler with the appropriate signature (such as Page_eventname) to the code-behind module for the page (or the server <script> block for pages that do not use code-behind). |