Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Do user controls need to be registered? View modes: 
User avatar
Member
Member
vcarter - 10/21/2013 2:18:28 PM
   
Do user controls need to be registered?
When developing locally I was able to create a filter control using webMatrix and simply reference that control using the "Filter" web part. It showed up on my page and filtered data as expected.

I sent my control to the Sys Admin for the client site I am working on. And he has copied the controls into the same place ~/CMSWebParts/Filters/FileName.aspx. However when I attempt to reference the control nothing happens.

Am I missing a step?

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 10/21/2013 3:58:13 PM
   
RE:Do user controls need to be registered?
Are you creating your own webpart? Or your own filter control? Both would have different starting points and references you may or may not need.

User avatar
Member
Member
vcarter - 10/22/2013 7:58:56 AM
   
RE:Do user controls need to be registered?
Filter control. When I built it in my local environment, all I needed to do was to create the user control and reference it. The problem I am having(without true access to the clients dev environment) is that I have to take their word that they put it where it is supposed to be, but as of right now, I am not seeing it. Which could be a bug in the actual control(i also have to develop on a dev version of kentico so I don't have full capabilities and needed to modify my working control after the fact to account for some custom tables).

I am thinking it has to be some minor bug. Just need a way to debug a control i cannot see.

User avatar
Member
Member
kentico_sandroj - 10/29/2013 10:34:10 AM
   
RE:Do user controls need to be registered?
Hello,

Custom filters do not require any type of additional registration. You would add the Filter Web part to a page and point it to the codefiles. If the filter is not showing on the page, I would suggest removing all custom code and simplifying the filter as much as possible in order to test. If it is not the code, the issue is likely somewhere in the configuration.

Please let me know if you have any questions.

Best Regards,
Sandro

User avatar
Member
Member
vcarter - 11/4/2013 10:11:25 AM
   
RE:Do user controls need to be registered?
sandroj: I based my controls off of the blog post by Karol. In his code he had the following when pulling data to bind to the drop downs:


private void IntializeRegions()
{
// Get administrator uder
UserInfo admin = UserInfoProvider.GetUserInfo("administrator");
if (admin != null)
{
// Get custom table provider
CustomTableItemProvider ctip = new CustomTableItemProvider(admin);
if (ctip != null)
{
// Get all businessUnits
DataSet regions = ctip.GetItems("Mynews.regions", null, "ItemID, ItemOrder ASC");
if (!DataHelper.DataSourceIsEmpty(regions))
{
// Bind businessUnits to drop-down list
this.drpRegion.DataSource = regions.Tables[0];
this.drpRegion.DataTextField = "regionName";
this.drpRegion.DataValueField = "ItemID";
this.drpRegion.DataBind();

// Add default '(all)' value
this.drpRegion.Items.Insert(0, new ListItem("(any)", "##ALL##"));
}
}
}
}




One question I have is regarding the admin variable. I am not sure what this is for. It seems to be making a check against administrator, but it also seems that this will always be true. I built my control with the developers version(v6 I believe) and I am deploying to the clients development server which is version 7. Is this check necessary? And is it possible that they do not have a default administrator account, thus causing my control to come up blank?

As I look at my code I also believe I have used the incorrect base class. Ultimately I will have two controls, one that connects to a custom query data source and one that connects to a document data source. I just noticed that my document data control is using the CMSAbstractQueryFilterControl base class. At the very least these revelations give me several things to debug.

Thank you for your assistance.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 11/4/2013 12:46:27 PM
   
RE:Do user controls need to be registered?
If you're using the proper Filter control syntax, your ascx control will inherit the CMSAbstractQueryFilterControl class.
public partial class MyControl_MyFilterControl : CMSAbstractQueryFilterControl
{

}
Then when you have done what you need to with your filter (set the WhereCondition, SelectTopN, etc.) you call
this.RaiseOnFilterChanged();

User avatar
Member
Member
vcarter - 11/4/2013 2:44:56 PM
   
RE:Do user controls need to be registered?
I actually got this working today. Not sure what changed on the clients end but the path appears to be working now. Very difficult to debug something like this with no real feedback from the source. As always thanks for the help.

:)

User avatar
Member
Member
kentico_sandroj - 11/4/2013 4:20:32 PM
   
RE:Do user controls need to be registered?
Hello,

I am glad to hear it is working now, it sounds like the issue was in the environment. As for your other question regarding admin, the following code is getting admin user info in order to initialize the CustomTableInfoProvider under administrator user context (to avoid permissions issues):

// Get administrator uder
UserInfo admin = UserInfoProvider.GetUserInfo("administrator");
if (admin != null)


If the admin object is not null, proceed with the rest of the code:

// Get custom table provider
CustomTableItemProvider ctip = new CustomTableItemProvider(admin);
if (ctip != null)
{.....


Please let me know if you have any additional questions.

Best Regards,
Sandro

User avatar
Member
Member
vcarter - 11/5/2013 8:53:44 AM
   
RE:Do user controls need to be registered?
Thanks again sandroj, that is what I figured, but IMO it never hurts to ask.