Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 22nd, 2004, 02:56 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default Protected Overrides Sub OnInit Ques

Hello I have some sample code. What is this code used for???
There is no explanation in Wrox book that I am using.


' Page Events
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        Protected Overrides Sub OnInit(ByVal e As EventArgs)
            MyBase.OnInit(e)
            InitializeComponent()
        End Sub


'This call is required by the Web Form Designer.
        <System.Diagnostics.DebuggerStepThrough()> _
        Private Sub InitializeComponent()
            AddHandler Me.Load, AddressOf Page_Load
        End Sub

 
Old September 22nd, 2004, 07:20 AM
Authorized User
 
Join Date: Jul 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is the standard delegate hook up. In other words, the Page_Load method in your page will be called at the proper time in the life time of the page.
Page_Load(..)
{
 if(!PostBack)
{
 bind your controls
}
else
{
 process post back data
}

}


This default hook up in the default method used by the IDE. Your could also override the OnLoad() of the page.

 
Old September 22nd, 2004, 07:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Just add to the end of the sub routine:

Private sub Page_Load(..) Handles MyBase.Load

That is the equivalent to the one you posted, but easier. That approach is useful for when (say for example) you create a linkbutton (in the code behind page, and add it to a controls collection), and want a method to be fired when that button is clicked.

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
Password Protected IE mrzoab C# 2 September 7th, 2007 07:47 AM
What is the use of protected keyword in C++? Konan C++ Programming 1 July 28th, 2006 05:04 AM
Protected Area Demo ASP.NET 2.0 Basics 0 May 25th, 2006 12:12 PM
Protected access wourouds BOOK: Beginning Java 2 4 March 18th, 2004 03:27 AM
Overrides keyword Ned VB.NET 1 September 16th, 2003 02:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.