Custom Field Type with Custom editor problem

Last post 07-10-2009 9:24 AM by nlvraghavendra. 2 replies.

Sort Posts:

  • Custom Field Type with Custom editor problem

    07-10-2009, 4:00 AM
    • Member
      2 point Member
    • nlvraghavendra
    • Member since 07-09-2009, 6:02 AM
    • Chennai, India
    • Posts 8

    Hi guys,

    I'm a newbie in sharepoint technologies. I've been trying for a week to create a custom field type (Simple Lookup) with a custom editor (simpleLookupEditor.ascx). I previously hardcoded the URL and the List to be shown in the column and it worked smoothly. When i created a user control file for the field type editor to get the URL and a list in that URL its not working. I've been studying all the posts regarding this. When i use the property schema the editor is loading while creating the column. But when i use the ascx file and assign it using FieldEditorUserControl property in the field type definition its not loading at all. When i select the Radio Button corresponding to my custom field type the page is loading and showing "Unknown Error". In what cases will i get this error? I've checked everything in fldypes*.xml and singleLookupEditor.ascx file. I'm not able to figure out the problem. Even if i try to debug its not hitting the breakpoints.

    fldtypes_SingleLookupType.xml

    <?xml version="1.0" encoding="utf-8"?>
    <FieldTypes>

    <FieldType>

    <Field Name="TypeName">SingleLookup</Field>
    <Field Name="ParentType">Lookup</Field>
    <Field Name="TypeDisplayName">Single Lookup Field</Field>
    <Field Name="TypeShortDescription">MPP Single Lookup</Field>
    <Field Name="UserCreatable">TRUE</Field>
    <Field Name="ShowOnListCreate">TRUE</Field>
    <Field Name="ShowOnSurveyCreate">TRUE</Field>
    <Field Name="ShowOnDocumentLibrary">TRUE</Field>
    <Field Name="ShowOnColumnTemplateCreate">TRUE</Field>
    <Field Name="Sortable">TRUE</Field>
    <Field Name="Filterable">TRUE</Field>
    <Field Name="FieldEditorUserControl">/_controltemplates/singleLookupEditor.ascx</Field>
    <Field Name="FieldTypeClass">SingleLookup.singleLookupField, SingleLookup, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b37a28ad0c406b9e</Field>
    <Field Name="SQLType">nvarchar</Field>

    </FieldType>

    </FieldTypes>


    singleLookupEditor.ascx


    <%@ Control Language="C#" Inherits="SingleLookup.singleLookupEditor,SingleLookup, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b37a28ad0c406b9e"  compilationMode="Always" AutoEventWireup="false" %>
    <%@ Register TagPrefix="wssuc" TagName="InputFormControl" src="~/_controltemplates/InputFormControl.ascx" %>
    <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Import Namespace="Microsoft.SharePoint" %>

    <wssuc:InputFormControl runat="server" LabelText="URL">
    <Template_Control>
    <asp:TextBox ID = "chkURL" runat = "server" Width = "150px"></asp:TextBox>
    <asp:Button ID = "go" runat = "server" Text = "GO"></asp:Button>
    </Template_Control>
    </wssuc:InputFormControl>

    <wssuc:InputFormControl runat="server" LabelText="Select List">
    <Template_Control>
    <<asp:DropDownList id="ddlList" runat="server" Width = "120px"></asp:DropDownList>
    </Template_Control>
    </wssuc:InputFormControl>


    singleLookupEditor.cs


    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.WebControls;

    namespace SingleLookup
    {
    public class singleLookupEditor : UserControl, IFieldEditor
    {
    protected DropDownList ddllist;
    protected Button go;
    protected TextBox url;
    private SPSite site;
    private SPWeb web;
    private String surlEditor;
    private String slistEditor;

    private singleLookupField classobj;

    public void InitializeWithField(SPField field)
    {
    this.classobj = field as singleLookupField;
    if (this.Page.IsPostBack)
    {
    return;
    }
    ddllist.SelectedIndex = 0;
    url.Text = "";
    if (field != null)
    {
    url.Text = classobj.url1;
    ddllist.SelectedValue = classobj.list1;
    //EnsureChildControls();
    }
    else
    {
    url.Text = "";
    ddllist.SelectedIndex =0;
    //EnsureChildControls();
    }
    }

    //protected override void CreateChildControls()
    //{
    // base.CreateChildControls();

    // go.Click += new EventHandler(go_Click);
    // ddllist.SelectedIndexChanged += new EventHandler(ddllist_SelectedIndexChanged);

    // if (!this.IsPostBack)
    // {
    // if (string.IsNullOrEmpty(url.Text))
    // {
    // ///
    // }
    // else
    // {
    // url.Text = this.url.Text;
    // ddllist.SelectedIndex = 0;
    // }
    // }
    //}

    public void OnSaveChange(SPField field, bool isNew)
    {
    singleLookupField obj = (singleLookupField)field;
    obj.url1 = this.url.Text;
    obj.list1 = this.ddllist.SelectedValue;

    }

    void ddllist_SelectedIndexChanged(object sender, EventArgs e)
    {

    surlEditor = this.url.Text;
    slistEditor = this.ddllist.SelectedValue;
    //throw new Exception("The method or operation is not implemented.");
    }

    void go_Click(object sender, EventArgs e)
    {

    site = new SPSite(url.Text);
    web = site.OpenWeb();
    SPListCollection col = web.Lists;
    ddllist.Items.Clear();
    foreach (SPList li in col)
    {
    ddllist.Items.Add(li.ToString());
    }

    //throw new Exception("The method or operation is not implemented.");
    }

    public bool DisplayAsNewSection
    {
    get
    {
    return true;
    }
    }
    }
    }






    Regards
    Raghavendra
  • Re: Custom Field Type with Custom editor problem

    07-10-2009, 8:32 AM
    • All-Star
      77,879 point All-Star
    • jeff@zina.com
    • Member since 09-26-2003, 10:43 AM
    • Naples, FL, USA
    • Posts 10,591
    • Moderator
      TrustedFriends-MVPs

    nlvraghavendra:
    I'm a newbie in sharepoint technologies.
     

    Then you're not a hosting service asking about hosting Sharepoint sites for customers?  That means you didn't read the announcement post at the top of this forum and wouldn't realize why you're posting your question in the wrong place:

    http://forums.asp.net/t/1047141.aspx

    Jeff

    Blatant Self Promotion: ASP.NET 3.5 CMS Development
  • Re: Custom Field Type with Custom editor problem

    07-10-2009, 9:24 AM
    • Member
      2 point Member
    • nlvraghavendra
    • Member since 07-09-2009, 6:02 AM
    • Chennai, India
    • Posts 8

    You could have asked your moderator to study the announcement before he accepts posts like mine..sorry anyway..

    Regards

    Raghavendra

    Regards
    Raghavendra
Page 1 of 1 (3 items)