Generate a link in the c# code

  • Thread starter Thread starter bruce barker
  • Start date Start date
B

bruce barker

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)

| 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...
|
|
 
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...
 
this.Controls.Add(HL);
Literal l = new Literal();
l.Text = "<br/>\n";
this.Controls.Add(l);

Ricardo said:
Thx...

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


Tarun said:
Add
//this refers to the form
this.Controls.Add(HL);

Ricardo said:
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...
 
Thx...

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


Tarun said:
Add
//this refers to the form
this.Controls.Add(HL);

Ricardo said:
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...
 
Back
Top