Kentico 8.xx - Snippet to check if page type have alternative form name

This is the snippet for Kentico version 8.xx to check if page type have alternative form.

Code Behind

  public bool CheckIfPageTypeHaveAlternativeForm(string EditFormName,string classID)  
{
bool haveForm = false;
string strEditFormName = ValidationHelper.GetString(EditFormName, "");
if (classID != "")
{
if (CMS.DocumentEngine.CMSDataContext.Current.AlternativeForms.GetSubsetWhere("FormClassID = " + classID).Count > 0)
{
var DataInfo = CMS.DocumentEngine.CMSDataContext.Current.AlternativeForms.GetSubsetWhere("FormClassID = " + classID);
foreach (CMS.DataEngine.BaseInfo a in DataInfo)
{
string formName = ValidationHelper.GetString(a.GetValue("FormName"), "");
if (formName.Contains(strEditFormName))
{
haveForm = true; break;
}
}
}
}
return haveForm;
}


By
NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)

Popular posts from this blog

Example to disable save as certain file type in SSRS Report Viewer

Phone book application example - Java

Modal Popup Message Box ASP.NEt C# Example