how to implement this?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • soni2926@yahoo.com

    how to implement this?

    hi,
    I have a repeater on a page that's going to build out music content,
    images and links to cds. Some of these cds do not have links, and
    some do, the ones with links i'm going to have to open in a new page,
    so my links are going to look like:
    <a href="<%# Eval("linkhere" ) %target="_blank ">Link</a>
    something like that, now the problem is how do i build that for cds
    with no links, so they don't open up blank pages, maybe just have it
    so there is no link for them all together. is it better for me to
    just add another column to the datatable i'm getting back, that has
    _blank or nothing for the target attribute, or something else better?
    any suggestions?

    thanks.
  • sloan

    #2
    Re: how to implement this?


    You can expose a public method on the code behind to handle this mini logic
    situations.



    Here is a crappy example.



    This is a method on the CODE BEHIND page.


    protected string DetermineSearch ForLastNameURL( object
    EmployeeLastNam e)
    {
    //yes the "object" in the argument is on purpose

    string empLastName = EmployeeLastNam e.ToString();

    if(empLastName. Length>0)
    {

    return
    string.Format(" http://www.google.com/search?source=i g&hl=en&rlz=&q= {0}",
    HttpUtility.Url Encode(empLastN ame));
    }

    return "#";


    }



    Then..on the repeater (aspx code)

    <a href='<%# DetermineSearch ForLastNameURL( DataBinder.Eval (Container,
    "DataItem.LastN ame") )%>'>HERE</a>

    You can do the same for the target if you want.

    That's one way...there are others.




    But that is a great trick for mini rules like that.

    The above (should) create a link like this for a data bind for "Smith"

    <a href='http://www.google.com/search?source=i g&hl=en&rlz=&q= Smith'>HERE</a>

    and

    <a href='#'>HERE</a>
    for people who don't have a last name (ha ha)....Its just an example !!




    <soni2926@yahoo .comwrote in message
    news:a489632e-f93f-4bea-b92f-2d2b2f870782@i7 g2000prf.google groups.com...
    hi,
    I have a repeater on a page that's going to build out music content,
    images and links to cds. Some of these cds do not have links, and
    some do, the ones with links i'm going to have to open in a new page,
    so my links are going to look like:
    <a href="<%# Eval("linkhere" ) %target="_blank ">Link</a>
    something like that, now the problem is how do i build that for cds
    with no links, so they don't open up blank pages, maybe just have it
    so there is no link for them all together. is it better for me to
    just add another column to the datatable i'm getting back, that has
    _blank or nothing for the target attribute, or something else better?
    any suggestions?
    >
    thanks.

    Comment

    Working...