0

In custom field type class I am overriding JSLink property. So in this case BaseFieldControl stop working. Any chance to use this class with overridden JSLink?

UPDATE:

 public class LookupField : SPFieldLookup
 {
     private const string DefaultJSLink = "~layouts/Test/LookupField.js";
     public override string JSLink
     {
         get
         {
             return string.IsNullOrEmpty(base.JSLink) ? DefaultJSLink : base.JSLink;
         }
         set 
         { 
             base.JSLink = value; }
         }
     } 
}

For clearly understanding - first of all I want make some work on server side and after correct UI on client side. Is it possible on EditForm/NewForm?

  • 1
    Can you please edit question and show how you are overriding the Property? – Amal Hashim May 15 '15 at 12:46
  • @AmalHashim updated – DenRedSky May 15 '15 at 12:57
0

Try below override

public override string JSLink
{
    get
    {
        if (SPContext.Current != null && SPContext.Current.FormContext.FormMode == SPControlMode.Invalid)
                return "~layouts/Test/LookupField.js";
         else             
                return string.Empty;                
    }
    set
    {
        base.JSLink = value;
    }
}
  • This working good in case if we want make some magic on server for NewForm template and for example make some UI for View template. But in my case: #making server logic for NewForm template; #making good UI on client side for NewForm template; So if we use your overriding method - we can't make some changes with UI; – DenRedSky May 15 '15 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.