API Questions on Kentico API.
Version 5.x > API > get ref of masterpage and hide webpartzone View modes: 
User avatar
Member
Member
anshuman.shandilya-aonhewitt - 5/23/2012 12:24:06 AM
   
get ref of masterpage and hide webpartzone
Hi,

I want to have a reference of masterpage in my webpart code. If I can get that then i want to hide a specific webpartzone in that masterpage and on the same time add a new webpart in that zone.
for eg. if there is any error in a webpart, I will hide or clear webpartzone to display nothing and add a new webpart which will have error message in it.
I want to do it this way becoz in master page I have menus on top and sidebars which users wants to see even if there is an error. User wants to see error only in the content section.

Please advice.

Thanks
Anshuman

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 5/23/2012 3:40:27 AM
   
RE:get ref of masterpage and hide webpartzone
Hello,


If I get your point, you want to catch the error so that the rest of page can work, right?

The standard approach is using a try-catch-finally block - you can find more details by google since it is a general ASP.NET approach, for example:

http://www.codeguru.com/csharp/.net/net_asp/miscellaneous/article.php/c12385/Exception-Handling-Techniques-in-ASPNET.htm

Or do you need to hide web parts different from the one which throws the error?


Best regards,
Helena Grulichova

User avatar
Member
Member
anshuman.shandilya-aonhewitt - 5/28/2012 10:12:06 AM
   
RE:get ref of masterpage and hide webpartzone
I need to hide other webparts also in the same webpartzone and display the error webpart (webpart I created to display generic error).

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 5/30/2012 7:13:28 AM
   
RE:get ref of masterpage and hide webpartzone
Hello,


thank you for your reply.

In this case, this KB article should be helpful for you: http://devnet.kentico.com/Knowledge-Base/Web-parts---Controls/How-to-change-web-part’s-properties-from-a-differe.aspx


Best regards,
Helena Grulichova

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 5/30/2012 7:18:15 AM
   
RE:get ref of masterpage and hide webpartzone
Also this forum thread can be helpful: How do you find all the webparts and widgets on a page