Generate a link in the c# code

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...
|
|
 
R

Ricardo

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...
 
L

Lloyd Dupont

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...
 
R

Ricardo

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...
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top