Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Fuji Kusaka 2203 posts 4220 karma points
    Dec 14, 2012 @ 12:58
    Fuji Kusaka
    1

    Check if Multiple TextString is Empty

    Hi,

    Can someone point out why checking for Empty TextString is not working ?

    I have a multiple Text String on a document Type and running some check to see if its empty not to display a Div Container.

    Both are working for me 

    if(Model.HasProperty("test") && Model.HasValue("test")){}
    if(Model.HasProperty("test") && Model.GetProperty("test").Value != String.Empty){}

    //fuji

  • Stephen Davidson 216 posts 392 karma points
    Dec 14, 2012 @ 13:45
    Stephen Davidson
    0

    looks right to me? just wokring on the same thing myself kinda...

    if (@n.HasValue("staffImage")){<div><img src="@n.GetProperty("staffImage")" alt="@n.GetProperty("staffName")" Title="@n.GetProperty("staffName")" width="200" class="staffImage" /></div>}

     

  • Fuji Kusaka 2203 posts 4220 karma points
    Dec 14, 2012 @ 13:48
    Fuji Kusaka
    0

    Hi Stephen,

    So what happens if the Value of "staffImage" is empty ? does it still displays the <div> ?

    Btw are you using the build in multiText String in v4.9.1 ? 

    //fuji

  • Mike Chambers 636 posts 1253 karma points c-trib
    Dec 14, 2012 @ 13:55
    Mike Chambers
    0

    I've found that some times you think it's an empty string, but actaully it's returning a DynamicNull

    try writing out GetType() to see what you are actually getting..

    then you might need to do a  X.GetType() = typeOf("DynamicNull") as the check...

     

    also 4.11 think you can do  x.GetPropertyValue<string>("someprob")  to stong type... haven't gone that root wet as still working against 4.10

  • Stephen Davidson 216 posts 392 karma points
    Dec 14, 2012 @ 15:10
    Stephen Davidson
    0

    Hey Fuji,

    If the value is empty is displays nothing, no DIV and no Image. I am running 4.11.1 but I am using a single line text string.

    As Mike mentioned there is a chance the multiline text will put in characters even when its empty...hope this helps

    S

  • Fuji Kusaka 2203 posts 4220 karma points
    Dec 14, 2012 @ 15:13
    Fuji Kusaka
    102

    Not on my side still displayin the content. Am using v4.9.1 so what i did instead i added a boolean which does the trick 

    if(Model.Where("displayTest") && Model.HasProperty("test") && Model.GetProperty("test").Value != String.Empty){
  • Anthony Candaele 1197 posts 2049 karma points
    Sep 19, 2013 @ 15:35
    Anthony Candaele
    0

    I have the same problem with uComponents Multiple Textstring, although it is empty:

    <coPromotor><![CDATA[]]></coPromotor>

              <externalCoPromotor>

                <values />

              </externalCoPromotor>

     

    my code still passes this condition:

    if (Model.Content.HasValue("externalCoPromotor") && Model.Content.GetMultipleTextStrings("externalCoPromotor").Count() > 0)

                        {

                            foreach (var excopromotor in Model.Content.GetMultipleTextStrings("externalCoPromotor"))

                            {

                                        @excopromotor @:,&nbsp;

                             }

                        }

     

    Does anyone have an idea to check for an empty property of type Multiple Textstring ?

     

    thanks for your help,

    Anthony

  • Anthony Candaele 1197 posts 2049 karma points
    Sep 19, 2013 @ 15:38
    Anthony Candaele
    0

    it even passes this condition:

    if (Model.Content.HasValue("externalCoPromotor") && Model.Content.GetProperty("externalCoPromotor").Value != String.Empty && Model.Content.GetMultipleTextStrings("externalCoPromotor").Count() > 0)

                        {

  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 19, 2013 @ 15:53
    Fuji Kusaka
    1

    Hi Anthony,

    You could do something else like having boolean checkbox to enable user admin to display the content of the multiple textstring.

    Or make the count after

    @if(CurrentModel.HasValue("externalCoPromotor") && CurrentModel.GetProperty("externalCoPromotor").Value != String.Empty){
                               if(Model.externalCoPromotor.Count() > 0){
     foreach(var f in Model.externalCoPromotor){                                     
                                            @f.InnerText
                                        
                                       }
    }
    }

     

  • Anthony Candaele 1197 posts 2049 karma points
    Sep 19, 2013 @ 16:37
    Anthony Candaele
    1

    Hi Fuji,

    Thanks, this works:

    if (Model.Content.GetMultipleTextStrings("externalCoPromotor").Count() > 0){

                            foreach (var excopromotor in Model.Content.GetMultipleTextStrings("externalCoPromotor"))

                            {

                                        @excopromotor @:,&nbsp;

                                }

                            }  

  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 19, 2013 @ 16:41
    Fuji Kusaka
    1

    Great :)

Please Sign in or register to post replies

Write your reply to:

Draft