Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Ok, my google skills have failed me. I try and search for the answer but keep getting caught on custom control event, which is not what I want. Here is what I am trying to do.

 

I have a Class Called SiteUsers. In the class I have an event declared as such:

Public Event BadData(ByVal PropertyName as string)

 

Inside the class I have a property

 

Public Property UserName() As String
       Get
           UserName = m_Username
       End Get
       Set(ByVal Value As String)
       m_UserName = value
       RaiseEvent BadData("UserName")

       End Set
   End Property

 

Just for a test I was raising the event no matter what, just to make sure things were happy.

 

On my Code behind File I Declare the object

Private WithEvents oSiteUser as SiteUser

 

In the load event the object is getting set with a new statement passing it some needed code.

 

To capture the BadData event, I have the following

 

Private Sub BadData (ByVal PropertyName as string) handles oSiteUser.BadData

'Some code

End Sub

 

I set a break point on the Sub and it never gets called. What am I missing here? I am new to the ASP.NEt world, so I am not sure what I could be missing, or if the postback stuff is screwing me up. Thanks for any pointers you can hand my way.

"Nobody knows what I do until I stop doing it."
  • Administrators
Posted

IIRC (will check when I get home) your control needs to implement the IPostBackEventHandler interface (and possibly the IStateManager interface as well).

Something to look at for the time being anyway ;)

 

Also if you are serious about authoring server controls you could do a lot worse than invest in Developing ASP.NET Server Controls and Components.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

Mister E - I have put break points on the code. The raiseevent code is firing, the event handler is not firing.

 

PlausiblyDamp - This is not a server control, it's a normal class object. What I am trying to do, and maybe I will just not go this route, is trying to put all the validation in the class and not on the page itself. So I am trying to use the event to notify the page that the data entered was bad data.

 

I am trying to go with the whole business layer idea, where all the logic is in the class, and not in the UI (being the webpage and code behind).

 

Thanks for the help though, I am not sure if I am explaining myself.

"Nobody knows what I do until I stop doing it."

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...