+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / How to use Language Selector declaratively ?

How to use Language Selector declaratively ?

2 posts, 0 answered
  1. Majid
    Majid avatar
    10 posts
    Registered:
    17 Jan 2012
    29 Jun 2015
    Link to this post

    Hi,

    I want to use language selector in my user control.

    I did this 

     <sf:LanguageSelector runat="server" ID="lngSelector"></sf:LanguageSelector>

    and got this error :

    Server Error in '/' Application.

    Object reference not set to an instance of an object.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error: 

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace: 

    [NullReferenceException: Object reference not set to an instance of an object.] Telerik.Sitefinity.Web.UI.ItemSelector.GetScriptDescriptors() +276 Telerik.Sitefinity.Web.UI.FlatSelector.GetScriptDescriptors() +22 System.Web.UI.ScriptControlManager.RegisterScriptDescriptors(IScriptControl scriptControl) +175 Telerik.Sitefinity.Web.UI.SimpleScriptView.Render(HtmlTextWriter writer) +145 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +149 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +245 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +149 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +245 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +149 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +245 System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +14 System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +51 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +149 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +245 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +149 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +245 System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +393 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +48 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +149 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +245​

  2. Velizar Bishurov
    Velizar Bishurov avatar
    143 posts
    Registered:
    01 Dec 2016
    02 Jul 2015
    Link to this post
    Hi Majid,

    You have to set its DataKeyNames to "DefinedFrontendLanguages" or "DefinedBackendLanguages" in the backend to make it work like so:

    lngSelector.DataKeyNames = "DefinedFrontendLanguages";


    Regards,
    Velizar Bishurov
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
2 posts, 0 answered