Learning Kentico: Component Events

It's a good day today! Yey! Because I was also able to make the Component Events exercise working. 

At first, I encountered an error that says SelectDoctorEventArgs missing  a directive or assembly reference (screenshot below) 

missing a directive or assembly reference
missing a directive or assembly reference issue

And I tried to search a solution online for that until I saw this Dec 2015 Components article from Kentico Devnet site which is very helpful. He discussed about a common scenario where component events are being used (like in a communication of two webparts in a page), the explanation of the parameters, how it works and some example. 

So I tried to apply it. I have now the two webparts working separately (the doctor's appointment form and the appointment list) but the next challenge is how the two will communicate. I should be able to display the appointment list based on my selection from the doctor dropdown list. 

From that article, I was able to correct or do the ff: 

a. in registering and raising the component events, the component name is the web part id 
b. was able to use the tip that he has provided when using ArgsType method which was my problem (as you see on the first screenshot above)

So I added that in one of code behind of my two web parts, but I couldn't completely remove them because they were 3 errors. I know it's a noob thing to do, but I actually put the custom EventArgs in both of my two web parts. Tsskkkk. yeah right, it doesn't make any sense! And it didn't work. Heheh..so funny! 

And I was thinking, how could I make this like Global? So it brought me back to what I learned/blogged about Global events. Oh yeah, I re-read it - and wait? Sounds like a lot of things to do. I will do the register type of module thingie? No way! Heheheh. 

But good thing, Visual Studio has this bright bulb thingie where it suggested me to why not create a new file for it. So I followed it and everything is now working. Whohoooo! See below: :)

Tried selecting Dr. Queenie Roberts and it displayed the appointment lists for her. 

component events
Displaying appointments for the selected doctor

Checked it also in database and everything is working as expected. :) 

component events
Doctors and Appointment

I know it's just a little accomplishment, but I'm just so happy. I know I still have  A LOT OF LEARN but it feels good. :) I'm going home with a smile on my face. Charot! 

Till my next blog post! 

No comments:

Post a Comment

Post Top Ad