Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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
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>}
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 ?
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
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
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){
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 @:,
}
Does anyone have an idea to check for an empty property of type Multiple Textstring ?
thanks for your help,
Anthony
it even passes this condition:
if (Model.Content.HasValue("externalCoPromotor") && Model.Content.GetProperty("externalCoPromotor").Value != String.Empty && Model.Content.GetMultipleTextStrings("externalCoPromotor").Count() > 0)
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 }}}
Hi Fuji,
Thanks, this works:
if (Model.Content.GetMultipleTextStrings("externalCoPromotor").Count() > 0){
Great :)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
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
//fuji
looks right to me? just wokring on the same thing myself kinda...
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
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
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
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
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 @:,
}
}
Does anyone have an idea to check for an empty property of type Multiple Textstring ?
thanks for your help,
Anthony
it even passes this condition:
if (Model.Content.HasValue("externalCoPromotor") && Model.Content.GetProperty("externalCoPromotor").Value != String.Empty && Model.Content.GetMultipleTextStrings("externalCoPromotor").Count() > 0)
{
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
Hi Fuji,
Thanks, this works:
if (Model.Content.GetMultipleTextStrings("externalCoPromotor").Count() > 0){
foreach (var excopromotor in Model.Content.GetMultipleTextStrings("externalCoPromotor"))
{
@excopromotor @:,
}
}
Great :)
is working on a reply...