aspx page inherits from a 'Page' class (vb.net) : Page Class « Page Lifecycle « ASP.NET Tutorial

ASP.NET Tutorial
1. ASP.Net Instroduction
2. Language Basics
3. ASP.net Controls
4. HTML Controls
5. Page Lifecycle
6. Response
7. Collections
8. Validation
9. Development
10. File Directory
11. Sessions
12. Cookie
13. Cache
14. Custom Controls
15. Profile
16. Configuration
17. LINQ
18. ADO.net Database
19. Data Binding
20. Ajax
21. Authentication Authorization
22. I18N
23. Mobile
24. WebPart
25. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
ASP.NET Tutorial » Page Lifecycle » Page Class 
5. 1. 3. aspx page inherits from a 'Page' class (vb.net)
<%@ Page Inherits="ParentPage" src="Default.aspx.vb" %>

<html><body>
   <form runat="server">
      <asp:Label id="lblMessage" runat="server" />
   
      <asp:DataGrid id="DataGrid1" 
                    runat="server" 
                    AutoGenerateColumns="True" />
      </asp:DataGrid>
   </form>
</body></html>


File: Default.aspx.vb


Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Data
Imports System.Data.OleDb

Public Class ParentPage : Inherits Page
   public lblMessage as Label
   public DataGrid1 as DataGrid
   
   private strConnString as string = "Provider=" & _
      "Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=yourDatabase.mdb"
   private objConn as new OleDbConnection(strConnString)
   
   sub Page_Load(Sender as Object, e as EventArgs
      if Not Page.IsPostBack then
         FillDataGrid()
      end if
   end sub

   private sub FillDataGrid(Optional EditIndex as integer=-1)
      dim objCmd as OleDbCommand = new OleDbCommand("select * from tblUsers", objConn)
      dim objReader as OleDbDataReader
       
      try
         objCmd.Connection.Open()
         objReader = objCmd.ExecuteReader
      catch ex as OleDbException
         lblMessage.Text = "Error retrieving from the database."
      end try
       
      DataGrid1.DataSource = objReader
      DataGrid1.DataBind()
       
      objReader.Close
      objCmd.Connection.Close()
   end sub
    
End Class
5. 1. Page Class
5. 1. 1. Fundamental properties in The Page Class
5. 1. 2. aspx page inherits from a 'Page' class (C#)
5. 1. 3. aspx page inherits from a 'Page' class (vb.net)
5. 1. 4. Expose the control through a page property
5. 1. 5. Page.ErrorPage
5. 1. 6. Page.HasControls
5. 1. 7. Is page valid
5. 1. 8. Page.ResolveUrl
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.