Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the new features of Visual Studio2010 and .net4

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

What are the knowledge points of this article "what are the new features of Visual Studio2010 and .Net4?" most people do not understand, so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "what are the new features of Visual Studio2010 and .Net4" article.

1. Code fragment (Code Snippets):

Code snippets are pre-developed code templates that save us time thinking about syntax. In Visual Studio 2005 and Visual Studio 2008, many code snippets have been established. However, these only apply to hidden code (code behind). The code snippet supports JavaScript,HTML and ASP.NET tags in Visual Studio 2010. In the following screen, the shortcut menus for JavaScript and HTML clips are shown.

In JavaScript:

In Html:

2 、 New Profiles:

In previous versions of dotnet, we have seen the configuration of different development environments. Such as VB, Che, Web development and General Development. We choose an environment configuration according to our own needs. These choices will be made after visual studio is installed for the first time or through the import export option. Here are two Visual Studio 2010 configuration environments, both of which are developed by HTML. They are:

◆ Web Development .

◆ Web Development (Code Optimized).

◆ Web Development, configuration hides the customer object and the event bar at the top of the HTML Mode.

◆ Code Optimized, you will find that there is no code, designer tabs html editor.

◆ it provides a larger space to play with html.

After you install Visual Studio, you can choose a configuration the first time you use it. You can also change the configuration of your work environment by: Tools > Import & Export Settings > Reset all settings option. If there is no change in IDE, you must make it effective by reopening Visual Studio.

3 、 Generate From Usage:

In previous versions of ASP.NET, Microsoft introduced code refactoring from existing code to generate methods. In ASP.NET 4.0, Generate From Usage has a new concept that can generate properties, methods, classes, and other types based on existing code.

Write some code, select it, right-click the rightmost character, and you will get the option to extract properties and methods. This option is displayed only if you have not defined this identifier. For the following example, IntelliSense does not display options to extract attributes, for example, if you right-click the variable I.

4 、 Multi-Targeting:

You can create a version 2. 0 or 3. 0 project in Visual Studio 2008 instead of developing it with the default 3. 5. That is, there is an option to change the framework version of the development project. The same option function is also available in Visual Studio 2010, and improvements are made accordingly. In previous versions, if you used framework 2.0 to create a project. The sense of intelligence will still be able to display the types and members of version 3.5. If you are not sure about the members of the selected framework, you will have more opportunities to make mistakes. However, IntelliSense on Visual Studio 2010 will only show you the version of framework of your choice.

5 、 MultiMonitor:

Visual Studio 2010 provides us with the ability to move IDE's form beyond visual studio IDE and put it on the desktop. It also supports multifaceted viewing of different IDE forms. If we close Visual Studio and open it again, we will find all the forms where we placed them last time.

6 、 Code Navigation:

The new navigation allows us to search for terms faster in the file. But it can only search for your typed text in the App_Code folder class file. It does not apply to HTML or code-behind files. In the following example, it shows my typed function name, it navigates to the window, selects any one of the form, and it will be able to navigate to the selected function definition.

7 、 View Call Hierarchy:

This helps to view the use of functions and properties, for example, if you right-click a function name, it will tell your function to use a hierarchical list. If you click to view the call hierarchy, it will display a form that tells you the details of the function call: select the parameters that the window function call will display in the hierarchy and the location of the function call.

8. Highlight the code:

Select an identifier and IDE will highlight where you are being used. For example, I choose the variable I, which is highlighted in different uses.

9. Improvement of smart tips:

In Visual Studio 2008, when you select properties for an object, it will be arranged according to the order of the letters entered, providing you with intelligent tips. In Visual Studio 2010 it will show you group-based properties, for example, if your text box object is followed by typing text, it will show you Text, TextChanged, TextMode. It also supports Pascal's IntelliSense. For example, if you type TC, it will navigate the TextChanged members.

You can see the version 4. 0 ClientIDMode property in the image below: if we change the framework version from the project properties. It does not display this property of the text box.

10 、 EnablePersistedSelection:

When we select a row like the datalist or gridview control, if we move to another page, on the new page, it selects the same numbered row, although we only select it on the first page. To avoid this, ASP.NET 4. 0 introduces a new property for these controls, which is EnablePersistedSelection. If set to true, you will not be able to select the same number in other pages. For example, navigate to the original web page, and the first page displays the selected initially selected row.

11 、 Web.Config Transformation

Usually we need to set some values in web.config for our development environment, and then we manually change these values during deployment or testing. For example, if we have connection strings or any other combination of keys and values in the Web.config file, we will replace them when the project is released or deployed, and here we will use the new term: Web.Config Transformation. This is an automatic way to do this. Web.config settings can be overridden by other configuration files, such as web.release.config,web.debug.config, etc., during project debug and release.

These values will not overwrite the original web.config, but will be in the published web.config. With the help of transformation, we can replace, remove, delete a node and we can delete or set its own properties. For example:

1. Create a configuration file from configuration manager > New.

2. Name it TransformWebConfig. Select Release from the copy setting from option. This will create a TransformWebConfig.config.

3. Right-click web.config and select the 'Add config Transfroms' option. Open Web.config and add a test key and value.

Open TransformWebConfig.config and add the following line.

5. Right-click the project and select 'Create Package'. VS will get the value from the TransformWebConfig.config file, which will change the value in the web.config file we published. In the successfully generated OBJ folder, check the web.config under the TransformWebConfig folder, and you will see that the value of the keyword KeyOne is TestOnConfigurationConfig.

12 、 URL Routing:

Now, we see that the site's URL is a more specific SEO. Without displaying any descriptive information, the URL mapping in ASP.NET 2.0 gives us an option to achieve this functionality to some extent. We can provide exact URL navigation and URL display to users. Url routing was introduced in ASP.NET 3.5. Developers create different route processing classes depending on the number of url routings on the site. Due to the url routing option, the postback problem can be resolved.

You don't need to define routing for each individual handler class in ASP.NET 4.0. Set up a helper function, MapPageRoute, to help you achieve faster routing. These routes are registered in Application_Start. For this example of setting routing in the Global.asax SetRouting method, the first parameter is the friendly name of routing, the second parameter is to check URL for pattern matching, and the third parameter is to implement this function for the user on the aspx page. In Global.asax are:

Protected void Application_Start (object sender, EventArgs e) {SetRouting (System.Web.Routing.RouteTable.Routes);} private void SetRouting (System.Web.Routing.RouteCollection routeCollection) {routeCollection.MapPageRoute ("RouteFriendlyName", "MyWebsite/RequestParameterName", "~ / Book.aspx"); / / you can add other page routes with different names and combinations here}

Now Book.aspx will use the following code for further processing.

String Parameter= Page.RouteData.Values ["RequestParameterName"] .ToString (); if (Parameter== "Chemistry") {....} else if (Parameter== "Physics") {....}

Now, if the conditions are met, if we will first browse to localhost / MyWebsite / Chemistry.

13 、 Add Reference Dialog:

In previous versions of Visual Studio, when reference dialog box was opened, it would take some time to load the .NET assembly file until it loaded all references from GAC. Open the project tab by default and add a reference on Visual Studio 2010. If you mistakenly click on the .net or COM tab, you also have an option to unload all assemblies. As a result, Visual Studio IDE is not frozen as before.

14 、 Compressing Session Values:

The state values of processes outside the ASP.NET session are saved on the database or server. These are saved in serialized format. When sent to the server, more and larger session will consume more resources. Now, these can be compressed into a new build compressionEnabled property. This attribute to the sessionState element can be declared in web.config.

This option will be used for processes outside of session.

15 、 Dynamic lookup:

There is a new static type: dynamic. We can use it as the type of any object. If there is any use of it, we can get its error at run time. For example:

Dynamic integerValue = 1; dynamic stringValue = "a string"; dynamic Result = integerValue + stringValue

The output will be: string 1. But if you change the last line:

Dynamic Result = integerValue & stringValue

You will not get any of the following compilation errors, at run time, you will get the following errors.

Operator'& 'cannot be applied to operands of type' int' and 'string'

16 、 Optional Parameters

Prior to ASP.NET 4, to implement optional parameters, we created overloaded functions. But now in C#, there are no more restrictions on optional parameters. But optional parameters like VB must be placed last. For example:

Public void FunctionOptionalParam (string Name, int Age, string Country = "")

We can ignore the required values of optional parameters.

FunctionOptionalParam ("My Full Name", 20)

17 、 Named Parameters:

Named parameters can be ignored in the order of parameters, using named parameters in different orders. For example:

Public void FunctionNamedParam (int x, int y, int z)

The function call will be:

FunctionNamedParam (XRV 1, ZRV 3, YRV 2)

Before the order of the function declaration, although we set the value of Z for the parameter, these are still equivalent to x = 1, arrow = 2.

18 、 Meta Tags:

The HtmlMeta class can be used to dynamically add the tag of HTML meta and the name of HTMLMeta, and the content attribute can be used to dynamically add any relay tag name and its value at run time. There are two properties, MetaDescription and MetaKeywords, in the ASP.NET 4.0 Page class. These can be used to add meta values to the description and keyword elements in html at run time. These can refer to page properties in HTML or in this way:

Page.MetaDescription = "this is meta description"; Page.MetaKeywords = "this is a meta keyword"

If so, we see HTML generation like this:

19 、 Generating Client IDs:

The client-side ID of the web control is dynamically generated according to the parent control ID. So, if you use textbox in a user control, we have to see what kind of ID is produced for it in order to use it directly in client-side scripts. Sometimes these are dynamically changed the name of the user control as well as its child control ID. In ASP.NET 4.0, this problem can be solved by the ClientIDMode property of the page. It has the following possible values: AutoID, Static, Predictable and Inherit.

AutoID: is the default value for webpage and has the same functionality as previous versions of ASP.NET.

Static: set a static ID for the control, so we don't need to worry about the ID of the parent control, we can reference it using javascript. For example, a user control inside the textbox, it outside a ClientIDMode is set to static.

This user control contains textbox2:

This code will produce the following HTML:

If we remove the ClientIDMode= "static", the output Hu HTML will be:

It will produce ID like previous ASP.NET versions of textbox.

Predictable: if we set the value of ClientIDMode to Predictable in the gridview or listview control, it will concatenate the value of the ID,column of the control ID and Gridview and mention it on the ClientIDRowSuffiex property:

Gridview ID = "GridView1" ClientIDMode= "Predictable" ClientIDRowSuffix= "ItemID"

If there is a label control whose ID is Label1 in the template column of gridview, it is bound to the ItemID column. Its ID will be: ID= GridView1_Label1_200. If we use the web control outside of the data-bound control, set ClientIDMode to be equal to Predictable:

You can see that webcontrols is output outside one panel and another panel.

It will produce the ID of all web controls, which is the ID of the panel page plus the ID of the child control. Inherit: the WEB control defaults to the ID that inherits the parent container. Control can override the properties of its parent control. So I can set different values for ClientModeID.

20 、 Permanent Redirect:

In some cases, if the current page is out of date, we want to redirect the user to the newly developed page. We can use Response.Redirect to transfer the page to a new page. However, in this case, the search engine saves the old information of the page indexed by the search. In addition, if the user browses to the page, he will be redirected to the page and then use the command's response.redriect to help with the newly opened page.

However, a new command Response.RedirectPermanent in ASP.NET 4.0 can be used to change the header information on the server page. Therefore, if the user goes to redirect him directly to a new page, and saves him a two-line page. Update the discovery header on the site and the page and update its index information to display the latest information to re-index the same search engine.

21 、 New Browser Definitions:

In ASP.net 3.5, several browsers have been updated in recent years, including Google chrome and those that support blackberry smartphones. The HttpBrowserCapabilities class of ASP.Net 4.0has been updated to support new browsers.

22 、 Package/Publish:

Package/Publish provides commands for setting up publish and package. Configure debugging options, and like previous versions, Publish provides options for setting compilation and generation. If there is no SQL Express on the managed server or if you do not want to include published files, then select those files that are excluded from the App_Data folder. If you select the option to create a Web package like a ZIP file, it will create a deployed zip file. Otherwise, it will be the unzipped folder by default.

By default, packages are created under the application's OBJ folder. By default, it is not displayed in the solution browser until you select the Show all files option. We can also set the server Web application name and the physical path of the target server.

23 、 Deploy SQL:

The deployment SQL option allows you to set the connection string as part of the deployment. You can manually add a connection string with a different name and value, or you can export from web.config by pressing the import button. You can just select the schema script or database options. By displaying the source settings in a connection string, we can set the value of the target server for. You can also manually add database script files by clicking the add button. You can also change the SQL file to run on the server.

The above is about the content of this article on "what are the new functions of Visual Studio2010 and .Net4". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report