trouble with aspnet inline if statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dorandoran
    New Member
    • Feb 2007
    • 145

    trouble with aspnet inline if statement

    Code:
    <% if(txtEmpID.Text!=null) Response.Write("<a href='Assign_Dept.aspx?id=" + txtEmpID.Text + "&sname=" + txtlname.Text + ", " + txtfname.Text + "' + target='_new' + toolbar='no'' > Testing Response with IF </a>"); %>
    How come "Testing Response with IF" still shows up when txtEmpID is Null?
    Last edited by Frinavale; Apr 9 '09, 05:55 PM. Reason: Added code tags. Please post code in [code] [/code] tags.
  • dorandoran
    New Member
    • Feb 2007
    • 145

    #2
    Still same problem. The link should only appear if there is an ID in the txtEmpID textbox.

    Code:
    <% if (txtEmpID.Text != null)
    {
    Response.Write("<a href='Assign_Dept.aspx?id=" + txtEmpID.Text + "&sname=" + txtlname.Text + ", " + txtfname.Text + "' + target='_new' + toolbar='no'' > Click Here . . .</a>");
    }
    else
    {
    Response.Write("Please select a record.");
    }  
    %>

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      You are checking for null, not an empty string. check for the empty string too.
      I rather like string.IsNullOr Empty() for this purpose

      Comment

      Working...