Quote:
quote:Originally posted by bekim
Isn't there an option in VS.Net configuration to turn off this automatic reset of Handles MyBase.Load???
|
NO!!
It doesn't matter if VS puts that back in because
A) This:
Private Sub InitializeComponent()
AddHandler Me.Load, AddressOf Page_Load
End Sub
Private Sub Page_Load(...)
...
End Sub
Is the same as this:
Private Sub InitializeComponent()
End Sub
Private Sub Page_Load(...) Handles MyBase.Load
...
End Sub
B) No matter how many methods you have handling an event, they will all run...
Private Sub Page_Load1(...) Handles MyBase.Load
End Sub
Private Sub Page_Load2(...) Handles MyBase.Load
End Sub
Private Sub Page_Load3(...) Handles MyBase.Load
End Sub
Private Sub Page_Load4(...) Handles MyBase.Load
End Sub
SO... as has been stated, just let VS put that empty handler in there and don't put anything in it. It's pretty simple.
If you are so annoyed with what visual studio is doing to your code, don't use it! You can write all your code in any text editor you like and compile it all with the complimentary compilers provided along with the .NET framework and relieve yourself from the horribly forceful hands of visual studio.
One thing you could try is renaming the method. Seeing as Visual Studio is most likely seeing the name "Page_Load" and assuming you want that tied to the Page.Load event you might try changing the name to something less obvious to VS. If visual studio is seeing the add handler assignment and rewriting it that way, then you are probably out of luck. Of course, just switching to C# would eliminate this problem altogether because there is no "handles" keyword.