Search code examples
umbracoumbraco5umbraco-blog

Type True/False in Umbraco


We want to implement a check box[Type : true/false] in an DocumemtType in Umbraco.

Our current Project necessity is:

an check box which will decide whether an image should be an link or popup

The code goes this way ...

    var child= @Model;

    if(child.GetProperty("popUp").Value.ToString() == "1")
      {
        // true means image will act as popup
      }
     else
      {
         // false means image will act as link
      }

But the problem is an error is occurred "Cannot perform runtime binding on a null reference"

I have also tried code like ,

      if (child.GetProperty("popup").Value.Equals("1"))
             {

             }

or

      if (child.GetProperty("popup").Value.ToString().Equals("1"))
             {

             }

but still not able to get it. All suggestions are welcomed .


Solution

  • Used the below code and it worked fine for me

    var child= @Model;
    
    if(@child.popUp)
      {
        // true means image will act as popup
      }
     else
      {
         // false means image will act as link
      }