 |
| ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 26th, 2005, 05:23 PM
|
|
Registered User
|
|
Join Date: Aug 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Assign string to what object?
please excuse my rookie thinking here.
what webcontrol can i use to assign strings to. For example. I have the following string but now want to display the string on the page specifically to an object. my question is what object? Since it is returning an HTML string i don't think label would work. Thanks.
string test = "<a href=something>something</a>";
|
|

August 26th, 2005, 05:37 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
You can use an <asp:Literal> for that. It renders no other output than its Text property....
Cheers,
Imar
|
|

August 26th, 2005, 05:48 PM
|
|
Registered User
|
|
Join Date: Aug 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Imar,
Thanks for the reply, however; now it does not loop for me. To be more detailed, I am trying to output a list of files from a directory which is no problem. It works well, but when assigning it to an object it only returns 1 file out of 3. I also tried it using the table HTML Control. It's also the same as using <asp:Literal>
You or anyone's help would be greatly appreciated. Thanks in advan!
======================================
CS CODE:
======================================
private void Page_Load(object sender, System.EventArgs e)
{
DirectoryInfo directoryInfo = new DirectoryInfo(@"C:\Inetpub\wwwroot\crystal\admin\u tilities");
FileInfo[] dir = directoryInfo.GetFiles("*.aspx");
foreach(FileInfo fi in dir)
{
string strDirFiles = "<a href=\"" + fi.Name.ToString() + "\" target=\"_blank\">" + fi.Name.ToString() + "</a>";
dirFiles.InnerHtml = strDirFiles;
}
}
======================================
HTML CODE:
======================================
<table cellSpacing="0" cellPadding="5" width="100%" border="0">
<tr>
<td id="dirFiles" runat="server">
</td>
</tr>
</table>
|
|

August 26th, 2005, 05:54 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
You should append to the Text or InnerHtml property:
dirFiles.InnerHtml += strDirFiles;
or
dirFiles.Text += strDirFiles;
Imar
|
|

August 26th, 2005, 05:59 PM
|
|
Registered User
|
|
Join Date: Aug 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Imar you ROCK AND ROLL dude! I'm also new to C#. Good lesson for me. Greatly appreciate it. Have a great weekend!
|
|

August 26th, 2005, 06:06 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
It's probably better and easier to bind the results of GetFiles directly to a data repeating control, like the <asp:DataList>, <asp:Repeater> or <asp:DataGrid>
Search Google for these controls and how to use them.
Cheers,
Imar
|
|
 |