Oh [big sigh]...found it.
Does anyone have any idea why this would fail? I'm sure it was working 
previously.

<Where>
  <IsNotNull>
    <FieldRef Name="FileLeafRef"/>
    <Value Type="File"></Value>
  </IsNotNull>
</Where>

From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of 
Paul Noone
Sent: Thursday, 3 November 2011 11:15 AM
To: ozMOSS (ozmoss@ozmoss.com)
Subject: Validate custom EditorPart field

[cid:image002.png@01CC9A37.C3FBA730]Hi all,
I've taken my image gallery web part to the next level and moved all properties 
to an EditorPart class. Everything looks great and works nicely provided all 
properties have a value.
I have the following four properties which correspond to the screenshot.

*         oListName

*         SelectedColumn

*         ImgBeginsWith

*         AscDesc
However, I want the Filter field (ImgBeginsWith) to be optional, so that all 
items are returned when it's empty.
This was working fine before I recreated this property as a TextBox within the 
EditorPart section.
ImgFilter = new TextBox();
ImgFilter.TextMode = TextBoxMode.SingleLine;
ImgFilter.Text = string.Empty;
ImgFilter.CssClass = "UserInput";
ImgFilter.ToolTip = "Leave blank to return all images.";
panListSettings.Controls.Add(ImgFilter);
In my web part I then have:
public string _imgBeginsWith = string.Empty;

[WebBrowsable(false),
        Personalizable(PersonalizationScope.Shared)]
public string ImgBeginsWith
{
    get {
        if (_imgBeginsWith == string.Empty)
        {
           _imgBeginsWith = "";
       }
        return _imgBeginsWith;
    }
    set { _imgBeginsWith = value; }
}
And then I check it every way I know how here:

if (ImgBeginsWith != null && SPEncode.HtmlEncode(ImgBeginsWith) != string.Empty 
&& !string.IsNullOrEmpty(ImgBeginsWith))
{
    oQuery.Query = "<Where><BeginsWith><FieldRef Name=\"FileLeafRef\"/>"
        + "<Value Type=\"File\">" + ImgBeginsWith + 
"</Value></BeginsWith></Where>";
}
else
{
    oQuery.Query = "<Where><IsNotNull><FieldRef Name=\"FileLeafRef\"/>"
        +  "<Value Type=\"File\"></Value></IsNotNull></Where>";
}


Yet it ALWAYS runs the first query option!

Any help please?!?

<<inline: image002.png>>

_______________________________________________
ozmoss mailing list
ozmoss@ozmoss.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss

Reply via email to