Rick_Fla Posted March 28, 2005 Posted March 28, 2005 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. Quote "Nobody knows what I do until I stop doing it."
Mister E Posted March 29, 2005 Posted March 29, 2005 Try putting a breakpoint on the chunk of code where you are raising the event -- just to make sure it's firing. Quote
Administrators PlausiblyDamp Posted March 29, 2005 Administrators Posted March 29, 2005 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Rick_Fla Posted March 29, 2005 Author Posted March 29, 2005 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. Quote "Nobody knows what I do until I stop doing it."
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.