Some experiences and techniques using ASP.NET and Visual Studio.net2003

xiaoxiao2021-03-06  122

Author: Unknown Make of speed and contact I 1, do not copy ASPX files directly in VS, because copy when two files with the same class file to be copied, it should build an empty file, then copy the pages and code 2 When the project is completed, if you want to get a clean, only required items, you can use the method of copying the project, pay attention, the documentation containing the project will be compiled and copied, and the document that is not included will not Before replicated, before copying, you need to create a target empty site. Copy methods should be selected to share the generation method of each file in the 3.VS.NET. All files are compiled, content, embedded three kinds, for CS files, the method of generating the method should For compilation, for the ASPX file, it should be content, for resources like you want to embed the DLL, such as BMP images, ICO images, strings, etc., should be embedded in other files, all set to content 4.DataReader can solve, Don't use DataSet5. When you handle control, especially DataGird, try to use custom paging, then write your page yourself, don't use DataGrid's automatic paging feature, automatic paging performance is not good 6. Sometimes, a definition Web project, in the definition, its URL is defined, such as http: // localhost: 8001 /, but later the URL of the project may change, become http: // localhost: 8009, this time, open the project directly Will be successful, you can find the folder where the project source file is located, open the suffix for .Webinfo file with Notepad, modify the URL point to point 7. In VS.NET, add a form, inevitably add the corresponding CS file Sometimes, I hope to write code directly in the classic form of <%%> directly in the ASPX file. At this time, don't delete the CS class file directly. You should first display all files, then open the corresponding ASPX page, turn the head <% @ PAGE%> Double deletion in the instruction and then delete the CS file 8.cs1607: askEMBLY generation - Reference Assembly 'Assembly Name' is a localized Satellite Assembly error processing reason is due to Assembly.cs An attribute: [assembly: assemblycultureattribute ("")] Using incorrect values, the correct method is to change it to the default value This article is: http://weblogs.asp.net/jgaylord/archive/ 2003/08 / 22 / 25003.aspx9. Write a way to write a Windows event log: (Many people are 9CBS and MS newsgroups, I also asked, but nothing, the following method is what I have pondered) a, open the registry: hk_l_m / system / currentControlSet / Services / EventLog / Application Establish a item name is EventSource's name (this step, you can do it in the installation step when you do the project installation file, you don't have manual operation) B. In the code, use EventLog.WriteEntry to write the log because it is ASP.NET Running an account has no permissions to create an event source, but there is permission to read and write event logs 10, exclude and include items: For files that do not want to include in the final version, it should be excluded and excluded. Will not participate in compilation and project replication, if a folder is included, all of them will contain all the following levels 11. By default, the ASPX does not allow POST to contain HTML content, add ValidateRequest = "false" in the Page instruction.

6, you want to quote the controls of others, you can copy the DLL into the bin folder, then click Add Delete Tool to the Toolbox, and then select it into the toolbox 7. For HTML tags, want To change it to a server control, you can select and right click, select Run 8 on the server side, write a client event handling script to name the HTML tag or client control, then in the code view, select the corresponding control name and Events can be 9.Web controls, as long as named, can reference 10 in its label in the client script, and common code can be directly dragged into the toolbox as a tool reference 11. To reference user controls, you can drag directly The ASCX file of the user control is designed to the design window. The VS will automatically add the register tag 12. To prevent others from compiling, you can use the code chaos tools that come with the VS, add the DLL, then generate, the generated code is mainly for some ways. The name of the class is chaotic 13. To put the connection string into web.config, you can open the web.config file directly, join segment, in which When reference, first import namespace: system.configuration, use configurationSettings.appsettings ["DSN"] can be referenced 14. Not necessary, do not use DataBinder.eval, should be used ((DATAROWVIEW) (ContaNdataItem) [ The "column name"] is to access the data, but use this method, you must add <% @ Import Namespace = "System.Data"%> 15 on the top of the ASPX page. User control can also define attributes and methods, but if If the property is defined, the display section of the control may be done with a custom method, and cannot depend on the Page_Load event of the control, because for Page_Load, these custom properties are still not visible.

转载请注明原文地址:https://www.9cbs.com/read-101653.html

New Post(0)