Wrox Programmer Forums
|
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
 
Old August 26th, 2005, 05:23 PM
Registered User
 
Join Date: Aug 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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>";
 
Old August 26th, 2005, 05:37 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You can use an <asp:Literal> for that. It renders no other output than its Text property....

Cheers,

Imar
 
Old August 26th, 2005, 05:48 PM
Registered User
 
Join Date: Aug 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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">&nbsp;
</td>
</tr>
</table>

 
Old August 26th, 2005, 05:54 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You should append to the Text or InnerHtml property:

dirFiles.InnerHtml += strDirFiles;

or

dirFiles.Text += strDirFiles;

Imar
 
Old August 26th, 2005, 05:59 PM
Registered User
 
Join Date: Aug 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar you ROCK AND ROLL dude! I'm also new to C#. Good lesson for me. Greatly appreciate it. Have a great weekend!

 
Old August 26th, 2005, 06:06 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Connection String (Object) ssimkhan Visual Basic 2005 Basics 1 June 1st, 2007 10:41 AM
Connection String(object) ssimkhan Visual Studio 2005 1 May 31st, 2007 04:54 PM
Assign label or string to external html file Gin262 ASP.NET 2.0 Basics 2 May 30th, 2007 06:39 AM
Unable to assign string length of more than 256 rahulpokharna SQL Server 2000 3 January 12th, 2006 04:58 PM
Get reference to an object by its name(string) v_ganeshraju BOOK: Professional C#, 2nd and 3rd Editions 1 July 13th, 2004 07:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.