locked
What does If Not String.IsNullOrEmpty means RRS feed

  • Question

  • User945338570 posted

    hi,

    Can you please explain me what is the meaning of "If Not String.IsNullOrEmpty(ddl_userid.SelectedValue) Then" where it is exactly used?

    Wednesday, July 31, 2013 2:28 AM

Answers

  • User-2139489267 posted

    If Not String.IsNullOrEmpty(ddl_userid.SelectedValue)

    That means value is not null or not an empty string.

    where it is exactly used?

    When you want to check above criteria.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 31, 2013 2:34 AM
  • User-1716253493 posted

    See this dropdownlist

        <asp:DropDownList ID="ddl_userid" runat="server">
            <asp:ListItem Value="">No Body</asp:ListItem>
            <asp:ListItem Value="Me">Me</asp:ListItem>
            <asp:ListItem Value="You">You</asp:ListItem>
        </asp:DropDownList>

    First value is Empty String

    Your code checking if you select any item that has value (item 1 "Me" or item 2 "You") then do something

    Your code will not be executed if you select first item BLANK VALUE

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 31, 2013 2:38 AM

All replies

  • User-2139489267 posted

    If Not String.IsNullOrEmpty(ddl_userid.SelectedValue)

    That means value is not null or not an empty string.

    where it is exactly used?

    When you want to check above criteria.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 31, 2013 2:34 AM
  • User-1716253493 posted

    See this dropdownlist

        <asp:DropDownList ID="ddl_userid" runat="server">
            <asp:ListItem Value="">No Body</asp:ListItem>
            <asp:ListItem Value="Me">Me</asp:ListItem>
            <asp:ListItem Value="You">You</asp:ListItem>
        </asp:DropDownList>

    First value is Empty String

    Your code checking if you select any item that has value (item 1 "Me" or item 2 "You") then do something

    Your code will not be executed if you select first item BLANK VALUE

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 31, 2013 2:38 AM
  • User-1360095595 posted

    http://msdn.microsoft.com/en-us/library/system.string.isnullorempty.aspx

    For something basic like this you should get used to using Google/Bing. 

    Wednesday, July 31, 2013 2:40 AM