Friday, 30 August 2019

Add Custom property in page property and use in Sitefinity

 public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
            Bootstrapper.Initialized += Bootstrapper_Initialized;
        }

        void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
        {
            if (e.CommandName == "Bootstrapped")
            {
                EventHub.Subscribe<IPagePreRenderCompleteEvent>((x) =>
                {
                    if (!x.PageSiteNode.IsBackend)
                    {
                        var page = x.Page;
                        var siteNode = x.PageSiteNode;
                        if (!string.IsNullOrEmpty(siteNode.Attributes["IndigoPageTitle"]))
                        {
                            page.Header.Title = string.Format("{0}", siteNode.Attributes["IndigoPageTitle"]);
                        }
                    }
                });
            }
        }
}
----------------------------------------------
Register your custom property as per below step 




Add meta to sitefinity website site

------Register user control and use below code for meta data--------

-----------------xml file

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<meta-data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<url>
    <newurl value="nav-dividends/nav-dividends">
      <meta>
        <mAttributes>property</mAttributes>
        <mAttributesContent>mAttributesContent</mAttributesContent>
        <mContent>twitterCreator</mContent>
      </meta>
      <meta>
        <mAttributes>itemprop</mAttributes>
        <mAttributesContent>mAttributesContent</mAttributesContent>
        <mContent>twitterCreator</mContent>
      </meta>
    </newurl>
    <oldurl>http://localhost:60878/navs-dividends/nav-dividends</oldurl>
  </url>
</meta-data>
----------------------
try
            {
                string myurl = Request.Url.ToString().ToLower().Trim();
                string BrowseFileDomainName = ConfigurationManager.AppSettings["RootURL"].ToString();
                DataSet listofpage = new DataSet();
                listofpage.ReadXml(Server.MapPath(ConfigurationManager.AppSettings["pagemeta"].ToString()));
                myurl = HttpUtility.UrlDecode(myurl);

                if (BrowseFileDomainName.Contains(";"))
                {
                    string[] domainstr = BrowseFileDomainName.Split(';');
                    if (domainstr.Length > 0)
                    {
                        foreach (string strdomain1 in domainstr)
                        { //To Replace last forward slash from request string
                            myurl = myurl.Replace(strdomain1, "");
                        }
                    }
                }
                else
                {
                    myurl = myurl.Replace(BrowseFileDomainName, "");
                }
                if (myurl.Contains("/"))
                {
                    myurl = (myurl.Substring(myurl.Length - 1, 1) == "/") ? myurl.Substring(0, myurl.Length - 1) : myurl;
                }
                //BrowseFileDomainName = (BrowseFileDomainName.Substring(BrowseFileDomainName.Length - 1, 1) == "/") ? BrowseFileDomainName.Substring(0, BrowseFileDomainName.Length - 1) : BrowseFileDomainName;


                if (myurl.Trim() == "")
                {
                    myurl = "home";
                }
                //   Response.Write("myurl" + myurl);
                if (listofpage.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in listofpage.Tables[0].Rows)
                    {
                        if (listofpage.Tables[1].Rows.Count > 0)
                        {
                            foreach (DataRow dr1 in listofpage.Tables[1].Rows)
                            {
                                if (dr["url_id"].ToString().Trim().ToLower() == dr1["url_id"].ToString().Trim().ToLower())
                                {
                                    if (myurl.Equals(dr1["value"].ToString().Trim().ToLower()))
                                    {
                                        if (listofpage.Tables[2].Rows.Count > 0)
                                        {
                                            foreach (DataRow dr2 in listofpage.Tables[2].Rows)
                                            {
                                                try
                                                {
                                                    if (dr1["newurl_id"].ToString().Trim().ToLower() == dr2["newurl_id"].ToString().Trim().ToLower())
                                                    {
                                                        var page5 = (System.Web.UI.Page)Telerik.Sitefinity.Services.SystemManager.CurrentHttpContext.CurrentHandler;
                                                        var creatorMetaTag = new System.Web.UI.HtmlControls.HtmlMeta();
                                                        creatorMetaTag.Attributes[dr2["mAttributes"].ToString().Trim().ToLower()] = dr2["mAttributesContent"].ToString().Trim();
                                                        creatorMetaTag.Content = dr2["mContent"].ToString().Trim();
                                                        page5.Header.Controls.Add(creatorMetaTag);
                                                    }
                                                    // page5.Header.InnerHtml = "<meta " + dr2["mAttributes"].ToString().Trim().ToLower() + "=\"" + dr2["mAttributesContent"].ToString().Trim() + "\" Content=\"" + dr2["mContent"].ToString().Trim() + "\"/>";
                                                }
                                                catch (Exception ex)
                                                {
                                                 
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }

                    }
                }
            }
            catch (Exception ex)
            {
             
            }


Wednesday, 31 July 2019

Sitefinity error: ContentView control is in Master mode and no MasterViews exist in the Views collection defined by this control.

Error: ContentView control is in Master mode and no MasterViews exist in the Views collection             defined by this control.

Solution:  Restart the IIS

Monday, 13 May 2019

Delete functionality in sitefinity telerik:RadGrid

 <telerik:RadGrid>
 <MasterTableView DataKeyNames="ID,CategoryName,ParentCategoryID">
                <Columns>
    <telerik:GridTemplateColumn UniqueName="edit">
                        <ItemTemplate>
                             <asp:LinkButton ID="delete_LinkButton" runat="server" Text="delete" CommandName="delete"
CommandArgument='<%# Eval("ID")+";" + Eval("CategoryName") %>' OnCommand="delete_LinkButton_Click"></asp:LinkButton>
                             </ItemTemplate>
                    </telerik:GridTemplateColumn>
  </Columns>
            </MasterTableView>
  </telerik:RadGrid>
 protected void delete_LinkButton_Click(object sender, CommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "delete")
                {
                    if (e.CommandArgument.ToString().Contains(";"))
                    {
                        string info = e.CommandArgument.ToString();
                        string[] arg = new string[2];
                        char[] splitter = { ';' };
                        arg = info.Split(splitter);


                        int Cat_Id = Convert.ToInt16(arg[0]);
                        string Cat_Name = arg[1].ToString();


                        operation = "D";
                        int exists = CategoryManager.DeleteCategory(operation, Cat_Id, Cat_Name, null);
                        //int exists = 1;
                        if (exists == 1)
                        {
                            strDelMsg = "Deleted successfully!";
                            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "SavedSuccess", "alert('" + strDelMsg + "');", true);
                            BindSchemeCategories();
                        }

                        else
                        {
                            strDelMsg = "This record cannot be deleted as it is mapped!";
                            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "SavedSuccess", "alert('" + strDelMsg + "');", true);

                        }
                    }
                    else
                    {
                        strDelMsg = "This record cannot be deleted as it is mapped!";
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "SavedSuccess", "alert('" + strDelMsg + "');", true);

                    }
                }
            }
            catch (Exception ex)
            {

             
            }
        }

Tuesday, 2 April 2019

user control use in sitefinity and button submit time dropdown is reset with empty

Refrence: https://docs.telerik.com/devtools/aspnet-ajax/controls/ajaxmanager/how-to/load-user-controls

protected void Page_Load(object sender, EventArgs e)
        {
            //-----pramod
            if (this.CurrentControl != string.Empty)
            {
                LoadMyUserControl(CurrentControl, this.Page);
            }
}


protected void Page_Init(object sender, EventArgs e)
        {
           FunBindCategory();
        }

    private string CurrentControl
        {
            get
            {
                return this.ViewState["CurrentControl"] == null ? string.Empty : (string)this.ViewState["CurrentControl"];
            }
            set
            {
                this.ViewState["CurrentControl"] = value;
            }
        }
        private void LoadMyUserControl(string controlName, Control parent)
        {
            parent.Controls.Clear();
            UserControl MyControl = (UserControl)LoadControl(controlName);
            string userControlID = controlName.Split('.')[0];
            MyControl.ID = userControlID.Replace("/", "").Replace("~", "");
            parent.Controls.Add(MyControl);
            this.CurrentControl = controlName;
        }

protected void btnSubmit_Click(object sender, EventArgs e)
        {
           
                this.LoadMyUserControl("~/UserControls/BackendModule/SchemeCategory Master/ucSchemeCategory.ascx", this.Page);
string test= drpcategory.SelectedValue;

}

Monday, 25 March 2019

.NET Framework 4.7.1 or a later update is already installed on this computer.

Error: .NET Framework 4.7.1 or a later update is already installed on this computer.



Solution: Repair your Visual Studio with below Step

Step 1


Step 2




Thursday, 28 February 2019

Custom Field add in Umbraco CMS

This is folder structure
\App_Plugins\ChannelSelection
channelselection.controller.js
channelselection.html
package.manifest

file contain
------------channelselection.controller.js--------------------
angular.module("umbraco")
    .controller("My.ChannelSelectionController",
    function ($scope) {
        $.ajax({
            url: "/umbraco/api/Portfolio/GetDropdownList",
            dataType: "json",
            type: "GET",
            error: function () {
                //alert(" An error occurred.");
            },
            success: function (data) {
                console.log(JSON.stringify(data));
                $('#fillvalues').find("option").remove();
                var option = $("<option/>");
               // option.attr("value", "").text("Select Channel");
                $("#fillvalues").append(option);
             
                $.each(data, function (i, product) {

                    $.each(product.Channel, function (j, productj) {

                        option = $("<option/>");
                        option.attr("value", productj.Id).text(productj.Name);
                        $("#fillvalues").append(option);
                       // contentc += '    <li><a href="' + productj.link + '"><img src="' + productj.Image + '" alt="' + productj.Name + '" /></a></li>';

                    });
                });
                $('#fillvalues').val($scope.model.value);
            }
        });
        //alert('Control loaded');
    });

--------------------channelselection.html-------------
<div ng-controller="My.ChannelSelectionController">
    <select id="fillvalues"  ng-model="model.value"></select>
 
</div>
--------------------package.manifest---------------
{  
    //you can define multiple editors  
    propertyEditors: [    
        {
            /*this must be a unique alias*/
            alias: "My.ChannelSelection",
            /*the name*/
            name: "Channel Selection",
            /*the html file we will load for the editor*/
            editor: {
                view: "~/App_Plugins/ChannelSelection/channelselection.html"
            }
        }
    ]
    ,
    //array of files we want to inject into the application on app_start
    javascript: [
        '~/App_Plugins/ChannelSelection/channelselection.controller.js'
    ]
}