Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Displaying a text file's contents on a web form using C#
Message
From
19/12/2002 18:00:42
Larry Long
ProgRes (Programming Resources)
Georgia, United States
 
General information
Forum:
ASP.NET
Category:
Web forms
Miscellaneous
Thread ID:
00734400
Message ID:
00734719
Views:
16
Paul,

I found and have the identical solution that you show for the FileToString function and I found that I can dispay the text in a scrollable window if I use the web form textbox control and set the object's Wrap property to "Soft" for the horiz. scroll bar and the TextMode property to Multiline for vert. scroll bar...but I've run into another problem.

The file I'm displaying is a web form's FormName.aspx.cs file. It comes up ok, but when I issue a Server.Transfer to go to that form after displaying the file, I get an exception warning me about possible tampering and it tells me that I can avoid the error by setting a "requestValidation" property to false in the Page, but I can't find find the property. Any ideas there?

TIA,
Larry
>>I would like to display a text file's content in a scrollable web control. Can someone point me in the right direction? I can't locate the correct property to populate and also what is the equivalent of the VFP FileToString command.
>>
>>TIA
>>Larry Long
>
>If you're coming from a VFP background, you might want to download the Visual FoxPro Toolkit for .NET. It's great for finding out how to do things in .NET. You can download it from: http://www.gotdotnet.com/team/vfp/
>
>Here is the FileToString directly from that library:
>
>
>public static string FileToStr(string cFileName)
>{
>   //Create a StreamReader and open the file
>   StreamReader oReader = System.IO.File.OpenText(cFileName);
>
>   //Read all the contents of the file in a string
>   string lcString = oReader.ReadToEnd();
>
>   //Close the StreamReader and return the string
>   oReader.Close();
>   return lcString;
>}
>
>
>Surprisingly, I haven't seen a Web Form control that lets uses the TEXTAREA tag (which is what you need). In your case, you could probably just drop a label or placeholder control on the form (I like the label, but either should work). Clear the text of the label. In the codebehind page of the form that should display the textfile, just built the HTML manually and stuff it into the .Text property of the label:
>
>

>System.Text.StringBuilder sbText = new System.Text.StringBuilder;
>
>sbText.Append("