ASP.NET(vb.net) & Code-Behind Model Microsoft recommends dealing with dynamic program code by using the code-behind model, which places this code in a separate file or in a specially designated script tag. Code-behind files typically have names like MyPage.aspx.cs or MyPage.aspx.vb while the page file is MyPage.aspx (same filename as the page file (ASPX), but with the final extension denoting the page language).
ShotDev Focus:
- ASP.NET & Code-Behind Model
Example
CodeBehind.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="CodeBehind.aspx.vb" Inherits="CodeBehind" %> <html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <form id="form1" runat="server"> <asp:Label id="lblText" runat="server"></asp:Label> </form> </body> </html>
CodeBehind.aspx.vb
Public Class CodeBehind Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.lblText.Text = "ASP.NET Code Behind Style" End Sub End Class
Screenshot
1already…
…