More in this section

Forums / General Discussions / Change default Metafield

Change default Metafield

3 posts, 0 answered
  1. Tarun
    Tarun avatar
    81 posts
    14 Jan 2009
    02 Oct 2010
    Link to this post

    I tried to change default metafield from "Name" to "SuspectIP" in the GC module but I found problem when I insert record this metafield value is shown blank. I am attaching the web.config and ascx page code.

    <cmsEngine defaultProvider="Generic_Content">
            <add name="SuspectIP" urlRewriteFormat="[SuspectIP].aspx" urlWhitespaceChar="_" visible="False" defaultMetaField="SuspectIP" securityProviderName="" allowVersioning="True" applicationName="/SuspectIP" versioningProviderName="" allowComments="false" allowWorkflow="false" commentsModeration="true" connectionStringName="GenericContentConnection" type="Telerik.Cms.Engine.Data.Providers.DefaultProvider, Telerik.Cms.Engine.Data"></add>
                    <add key="SuspectIP.SuspectIP" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue=""/>

    Page code-
    <h3><asp:Label ID="Label1" AssociatedControlID="SuspectIP" Style="float: none;" runat="server">
              <asp:Literal ID="Literal3" runat="server" Text="<%$Resources:SuspectIP %>"></asp:Literal>
              * <em id="NameLabel" runat="server"></em>
          <fieldset class="set">
              <div class="setIn title">
                  <asp:TextBox ID="SuspectIP" Text="<%$Resources:NameInput %>" runat="server"></asp:TextBox>
                  <asp:RequiredFieldValidator ID="validator1" runat="server" ControlToValidate="SuspectIP" Display="Dynamic" EnableViewState="False" CssClass="validMessage" SetFocusOnError="True"><strong><asp:Literal ID="Literal4" runat="server" Text="<%$Resources:NameEmpty %>"></asp:Literal></strong></asp:RequiredFieldValidator>

    Am I doing wrong any thing wrong in code or config.Please check this and let me know the solution.

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    03 Oct 2010
    Link to this post
    Hi Tarun,

    1. Check whether your control is inside ContentMetaFields control tags. If the control is not there its value will not be persisted automatically.

    2. When you change the default metakey of a Generic_Content provider your metakey should be outside of ContentMetaFields control and you should get/set the value manually by using IContent object - GetMetaData and SetMetaData methods.

    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Tarun
    Tarun avatar
    81 posts
    14 Jan 2009
    03 Oct 2010
    Link to this post
    Thank you Ivan! 

    It was already outside of metafield control but once I get/set it manually it worked fine.

Register for webinar
3 posts, 0 answered