Generate a link in the c# code

Discussion in 'ASP .Net' started by bruce barker, Nov 11, 2004.

  1. bruce barker

    bruce barker Guest

    you have to add the controls to the form. to control where they appear,
    generally you use a placeholder control, then add to its control collection.

    -- bruce (sqlwork.com)

    "Ricardo" <> wrote in message
    news:...
    | I'm buiding a class that pick the files in a directory and shows in the
    | browser the links to download these files...
    | But i have to create the hyperlinks, and that part is not working...
    | I do the folow in the page_Load:
    |
    | DirectoryInfo dir = new DirectoryInfo(@"e:\shared files");
    |
    | FileInfo[] files = dir.GetFiles();
    |
    | foreach(FileInfo file in files)
    |
    | {
    |
    | HyperLink HL=new HyperLink();
    |
    | HL.Text=file.Name.ToString();
    |
    | HL.NavigateUrl=file.ToString();
    |
    | }
    |
    | But the hyperlinks doesn't show in the browse...
    |
    | Can someone help me??
    |
    |
    | []s...
    |
    |
    bruce barker, Nov 11, 2004
    #1
    1. Advertising

  2. bruce barker

    Lloyd Dupont Guest

    he mean something like
    myPlaceHolder.Controls.Add(HL);

    "bruce barker" <> wrote in message
    news:%...
    > you have to add the controls to the form. to control where they appear,
    > generally you use a placeholder control, then add to its control
    > collection.
    >
    > -- bruce (sqlwork.com)
    >
    > "Ricardo" <> wrote in message
    > news:...
    > | I'm buiding a class that pick the files in a directory and shows in the
    > | browser the links to download these files...
    > | But i have to create the hyperlinks, and that part is not working...
    > | I do the folow in the page_Load:
    > |
    > | DirectoryInfo dir = new DirectoryInfo(@"e:\shared files");
    > |
    > | FileInfo[] files = dir.GetFiles();
    > |
    > | foreach(FileInfo file in files)
    > |
    > | {
    > |
    > | HyperLink HL=new HyperLink();
    > |
    > | HL.Text=file.Name.ToString();
    > |
    > | HL.NavigateUrl=file.ToString();
    > |
    > | }
    > |
    > | But the hyperlinks doesn't show in the browse...
    > |
    > | Can someone help me??
    > |
    > |
    > | []s...
    > |
    > |
    >
    >
    Lloyd Dupont, Nov 11, 2004
    #2
    1. Advertising

  3. bruce barker

    Ricardo Guest

    I'm buiding a class that pick the files in a directory and shows in the
    browser the links to download these files...
    But i have to create the hyperlinks, and that part is not working...
    I do the folow in the page_Load:

    DirectoryInfo dir = new DirectoryInfo(@"e:\shared files");

    FileInfo[] files = dir.GetFiles();

    foreach(FileInfo file in files)

    {

    HyperLink HL=new HyperLink();

    HL.Text=file.Name.ToString();

    HL.NavigateUrl=file.ToString();

    }

    But the hyperlinks doesn't show in the browse...

    Can someone help me??


    []s...
    Ricardo, Nov 11, 2004
    #3
  4. Add
    //this refers to the form
    this.Controls.Add(HL);

    "Ricardo" wrote:

    > I'm buiding a class that pick the files in a directory and shows in the
    > browser the links to download these files...
    > But i have to create the hyperlinks, and that part is not working...
    > I do the folow in the page_Load:
    >
    > DirectoryInfo dir = new DirectoryInfo(@"e:\shared files");
    >
    > FileInfo[] files = dir.GetFiles();
    >
    > foreach(FileInfo file in files)
    >
    > {
    >
    > HyperLink HL=new HyperLink();
    >
    > HL.Text=file.Name.ToString();
    >
    > HL.NavigateUrl=file.ToString();
    >
    > }
    >
    > But the hyperlinks doesn't show in the browse...
    >
    > Can someone help me??
    >
    >
    > []s...
    >
    >
    >
    =?Utf-8?B?VGFydW4=?=, Nov 11, 2004
    #4
  5. bruce barker

    Lloyd Dupont Guest

    this.Controls.Add(HL);
    Literal l = new Literal();
    l.Text = "<br/>\n";
    this.Controls.Add(l);

    "Ricardo" <> wrote in message
    news:...
    > Thx...
    >
    > But how can I put one link per line???
    >
    >
    > "Tarun" <> wrote in message
    > news:...
    >> Add
    >> //this refers to the form
    >> this.Controls.Add(HL);
    >>
    >> "Ricardo" wrote:
    >>
    >> > I'm buiding a class that pick the files in a directory and shows in the
    >> > browser the links to download these files...
    >> > But i have to create the hyperlinks, and that part is not working...
    >> > I do the folow in the page_Load:
    >> >
    >> > DirectoryInfo dir = new DirectoryInfo(@"e:\shared files");
    >> >
    >> > FileInfo[] files = dir.GetFiles();
    >> >
    >> > foreach(FileInfo file in files)
    >> >
    >> > {
    >> >
    >> > HyperLink HL=new HyperLink();
    >> >
    >> > HL.Text=file.Name.ToString();
    >> >
    >> > HL.NavigateUrl=file.ToString();
    >> >
    >> > }
    >> >
    >> > But the hyperlinks doesn't show in the browse...
    >> >
    >> > Can someone help me??
    >> >
    >> >
    >> > []s...
    >> >
    >> >
    >> >

    >
    >
    Lloyd Dupont, Nov 12, 2004
    #5
  6. bruce barker

    Ricardo Guest

    Thx...

    But how can I put one link per line???


    "Tarun" <> wrote in message
    news:...
    > Add
    > //this refers to the form
    > this.Controls.Add(HL);
    >
    > "Ricardo" wrote:
    >
    > > I'm buiding a class that pick the files in a directory and shows in the
    > > browser the links to download these files...
    > > But i have to create the hyperlinks, and that part is not working...
    > > I do the folow in the page_Load:
    > >
    > > DirectoryInfo dir = new DirectoryInfo(@"e:\shared files");
    > >
    > > FileInfo[] files = dir.GetFiles();
    > >
    > > foreach(FileInfo file in files)
    > >
    > > {
    > >
    > > HyperLink HL=new HyperLink();
    > >
    > > HL.Text=file.Name.ToString();
    > >
    > > HL.NavigateUrl=file.ToString();
    > >
    > > }
    > >
    > > But the hyperlinks doesn't show in the browse...
    > >
    > > Can someone help me??
    > >
    > >
    > > []s...
    > >
    > >
    > >
    Ricardo, Nov 12, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Weng Tianxiang
    Replies:
    5
    Views:
    1,298
    Christophe
    Feb 16, 2006
  2. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    794
    Kevin Spencer
    May 17, 2005
  3. Replies:
    3
    Views:
    396
    red floyd
    Apr 7, 2006
  4. Harlan Messinger
    Replies:
    2
    Views:
    2,278
    John Bell
    Mar 28, 2010
  5. uandme72
    Replies:
    4
    Views:
    166
    Daniel Crichton
    Mar 27, 2009
Loading...

Share This Page