#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2008
    Location
    chennai
    Posts
    13
    Rep Power
    0

    How to use IF statement in ASP.NEt Inline Code?


    hi frnds,
    i have one search page with two categories (i)Forums (ii)Blogs.
    If i enter search string in textbox and check "Forums" category then click search button it returns forums topics, for that i wrote coding

    Code:
    <td>
    <h2>
    <a href='<%#forums.ForumsUtilities.GetForumURL(Eval("TopicID"),
    Eval("Subject")) %>'><%# Eval("Subject") %></a>
    </h2>
    </td>
    If i check "Blogs" then need to return blog topics in same repeater.
    How to do that anyone have idea inform me... how to use if statement in Inline code.The code for blogs is,
    Code:
    <td>
    <h2>
    <a href='<%#forums.ForumsUtilities.GetBlogURL(Eval("TopicID"), Eval("Subject")) %>'><%# Eval("Subject") %></a>
    </h2>
    </td>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2006
    Posts
    111
    Rep Power
    14
    <a href="<% If {statement} Then Response.Write("Blah Blah Blah") %>"></a>

    Or Maybe:

    <%
    If {statement} Then
    Response.Write("<a href=""url.aspx""></a>")
    Else
    Response.Write("<a href=""someotherUrl.aspx""></a>")
    End If
    %>
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2009
    Posts
    837
    Rep Power
    527
    Originally Posted by sasil
    hi frnds,
    i have one search page with two categories (i)Forums (ii)Blogs.
    If i enter search string in textbox and check "Forums" category then click search button it returns forums topics, for that i wrote coding

    Code:
    <td>
    <h2>
    <a href='<%#forums.ForumsUtilities.GetForumURL(Eval("TopicID"),
    Eval("Subject")) %>'><%# Eval("Subject") %></a>
    </h2>
    </td>
    If i check "Blogs" then need to return blog topics in same repeater.
    How to do that anyone have idea inform me... how to use if statement in Inline code.The code for blogs is,
    Code:
    <td>
    <h2>
    <a href='<%#forums.ForumsUtilities.GetBlogURL(Eval("TopicID"), Eval("Subject")) %>'><%# Eval("Subject") %></a>
    </h2>
    </td>
    You should be using code-behind and not inline code.

    Inline code is a nightmare to maintain, and does not properly separate the presentation from the data.

IMN logo majestic logo threadwatch logo seochat tools logo