You must use the directive and use the Inherits and CodeFile attributes to link the code-behind file to the. For more information, see Script Exploits Overview.
By default, ASP.NET Web pages validate that user input does not include script or HTML elements. This example has a text box that accepts user input, which is a potential security threat. aspx file that corresponds to the preceding code-behind source file. MySpan.InnerHtml = 'Hello, ' + MyTextBox.Text + '.' Protected Sub SubmitBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyButton.Click Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Protected void SubmitBtn_Click(object sender, EventArgs e) Define a handler for the button click. Protected void Page_Load(object sender, EventArgs e) Public partial class M圜odeBehindCS : .Page Furthermore, note that the partial class allows the code-behind file to use controls defined on the page without the need to define them as field members. The base page class can be Page, or it can be another class that derives from Page. Note that the code-behind source file declares a partial class that inherits from a base page class. The following code example demonstrates how the Page class is used in the code-behind page model. A Visual Studio Web site project with source code is available to accompany this topic: Download.