Time:2006.9.28Author:Anytao
2006Anytao.com Please indicate the source of the post and keep this information
Introduction:
InWebDuring development, operations on files are often performed. This isProgramOne of the necessary lessons for design. ImproveASP. NETDesign capability, familiar with the use of controls, database operations,XMLIn addition to technology, file read and write operations are also improvedWebOne of the greatest advantages of design and development.
This article describes howWebThe page reads text information to change the background information of the page that is not often updated, because the information that is not often updated, such as pages, website introductions, website maps, etc, there is no need to implement it in the form of a database. The design complexity and system overhead are unnecessary.
Basic Information
Development Environment:Vs2003Tools,. NetPlatform, C #Language
Technical points:ASP. NETFile stream read/write,TableDynamic use of controls
Solution
1Create a project, set the directory, and the text information to be displayed. This article establishes a dynamic implementation of a webpage link here. Therefore, two text files are created, which are the webpage names.Link.txtAnd webpage addressUrl.txtFor the benefits of this implementation, seeCode.
2JoinTable, Set itsStyle.
3InPage_load (), Add the code implementation for loading text information.
1 Private Void Page_load ( Object Sender, system. eventargs E)
2 {
3 // Place user code here to initialize the page
4 // Read File Path
5 String Filenameurl = Server. mappath ( @" Blogtext \ url.txt " );
6 String Filenamelnk = Server. mappath ( @" Blogtext \ link.txt " );
7
8 // Read text files to file streams
9 Streamreader srurl = New Streamreader (filenameurl );
10 Streamreader srlnk = New Streamreader (filenamelnk );
11
12 String Strurl, strlnk;
13
14 While (Srurl. Peek () ! =- 1 )
15 {
16 Strurl = Srurl. Readline ();
17 Strlnk = Srlnk. Readline ();
18
19 // You can use two text files to easily separate URLs from text files.
20 Hyperlink hlnk = New Hyperlink ();
21 Hlnk. Visible = True ;
22 Hlnk. Text = Strurl;
23 Hlnk. navigateurl = Strurl;
24
25 // Other methods can be used for dynamic implementation
26 // Dynamically add text information to a table
27 Tablerow tr = New Tablerow ();
28 Tablecell TC1 = New Tablecell ();
29 Tablecell TC2 = New Tablecell ();
30
31 Tc1.text = Strlnk;
32 Tc2.controls. Add (hlnk );
33 Tr. cells. Add (TC1 );
34 Tr. cells. Add (TC2 );
35 Tabtext. Rows. Add (TR );
36
37 }
38
39 }
40
4Run to view,OK.
Conclusion
File operations are the basic content of program development and need to be further improved. In this example, you can try to useDatasetAndXMLIt is more flexible and can be further explored.
I hope you will join the bricks and eggs, and I will try my best to move forward in the storm.
Enjoy.
About the author
After several years of learning, I woke up with technology and thought about the world. Internal focus on. Net, External discussionsDelphiIn the capital of Beijing, zomeng is dedicated to funding. By virtue of the column, the mission is to establish an industry-based preaching, and to learn from all corners of the world, and to cultivate the technology of China.
Stay tunedAnytao.com.
2006Anytao.com Please indicate the source of the post and retain this information.