Click here to Skip to main content
15,898,373 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a user control and it only binds a gridview. i like to set a delegate event and call it at various pages. this is in asp.net vb.
user control
VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not IsPostBack Then
             Call bindGV()
        End If

    End Sub
Posted
Updated 26-Jan-12 20:44pm
v2
Comments
Sergey Alexandrovich Kryukov 26-Jan-12 21:06pm    
Please do yourself a favor: change the tag "VB" into "VB.NET".
--SA

1 solution

You cannot "call an event", it is not a method. You can invoke event, and only in the class where the event was declared; it is impossible to invoke it anywhere else, not even in a derived class. This is one of important limitations of the events compared with "regular" delegate instances, an important fool-proof feature used to prevent even misuse.

The code using the class can only add a handler to the invocation list of the accessible even instance of an instance of the class.

What are your trying to do is not clear, but you certainly need to understand how events and delegates work first. You either need to use something else, not an event, or you need to do something else.

What you think you want to do is formally impossible, but probably you still need to do something reasonable. That's why you also need to explain your ultimate goals in your question, without using your understanding how to achieve it technically, as you could be preoccupied with some wrong idea.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900