ASP. NET project Summary

Source: Internet
Author: User
Tags connectionstrings

Well, for the first time, a formal project was developed with ASP. Tired. has been in the key details, now put this week to learn the things summed up, novice to more summary!

First, JS summary

First, load the JS file. In the. cshtml file, there are many ways to load JS, which can be loaded directly with tags.

@section headerjs{    <link rel= "stylesheet" type= "Text/css" href= "... /content/css/indexstyle.css "/>    <link rel=" stylesheet "href=". /content/js/ztree/css/ztreestyle/ztreestyle.css ">    <script src=". /content/js/ztree/js/jquery.ztree.all-3.5.js "></script>    <script src=". /scripts/tableexport.js "></script>    <script src=". /scripts/jquery.base64.js "></script>    <script src=". /.. /content/js/public.js "></script>    <script type=" Text/javascript ";}

As can be seen from the above example, this method can be used to load. js,. css files into the. cshtml file. You can define your own. js file and then load it in this way. This allows you to use the functions in the. js file in this file. such as the Public.js file is as follows:

Formats the time function Formattime (dateTime) {    var date = new Date (parseint ("/date (" ") in the JSON data. Replace (")/", ""), ());    var month = Date.getmonth () + 1 < 10? "0" + (date.getmonth () + 1): Date.getmonth () + 1;    var currentdate = date.getdate () < 10? "0" + date.getdate (): Date.getdate ();    var hour = date.gethours () < 10? "0" + date.gethours (): Date.gethours ();    var min = date.getminutes () < 10? "0" + date.getminutes (): Date.getminutes ();    return date.getfullyear () + "-" + month + "-" + currentdate + "" + Hour + ":" + min;}


This allows you to use the Formatetime () function directly in the HEADERJS section.

The use of Ztree.

explained in another article.

ASP. NET MVC 3 Export Import HTML table to CSV file

explained in another article.

HTML checkbox Select All and uncheck all implementations

function Changecheckboxstate () {        $ ("#chkcheckall"). Click (function () {            $ ('. Radio '). Prop ("Checked", this.checked);}        );     }

One problem here is that the Change event of the checkbox cannot be used. In IE, the checkbox in the first point does not trigger the change event, bypassing the issue directly with the Click event.

Determine if the browser is IE

function Isie () {//ie?                if (!! Window. ActiveXObject | | "ActiveXObject" in window) {                    return true;                }                if (Navigator.userAgent.split (";") [1].tolowercase (). IndexOf ("msie") = = "1") {                    return false;                } else {                    return true;                }            }

This is lost to ie, ie 11 useragent inside there is no "ie" character, this has to pit out how many people. The first if statement is used to determine if it is IE 11.

Two, ASP. NET MVC Summary

First, the Controller

In the Controller, there are many ways to return to a view, such as:

Return Content ("OK");

        //Summary:        //     use a string to create a content result object. ////        Parameters:        //   content:        //     contents to write to the response. ////        return Result:        //     content result instance. Return Content ("OK");///        Abstract:        //     Create a System.Web.Mvc.JsonResult object that serializes the specified object using the specified JSON request behavior JavaScript Object Notation        //     (JSON) format. ////        Parameters:        //   data:        //     JavaScript object graph to serialize. /////   behavior:        //     JSON request behavior.        ////        returns Result:        //     serializes the specified object to a result object in JSON format. return Json (data, jsonrequestbehavior.allowget);/////        Abstract:        //     Create a view to render to the response The System.Web.Mvc.ViewResult object.        ////        Returns the result:        //     renders the view to the response view result. return view ()////        Summary:        //     Create a System.Web.Mvc.PartialViewResult object that renders the partial view. ////        return Result:        //     partial View result object. return Partialview ();

This needs to go to the MSDN documentation, which can be used at any time and need to know what they are doing. There is an introduction in System.Web.Mvc.Controller.

Iii. Summary of Entity Framework

The Entity framework is a very useful OA framework. Very easy to get started, if the project is small and you don't want to use the database, you can use EF to generate a local. mdb file as a data storage tool. One problem is that, when connecting to a remote database, Server Explorer is able to connect to the database, but EF always reports that it cannot open a connection error. This is definitely the URL connection information setting error.

  <connectionStrings> <!--<add name= "defaultconnection" connectionstring= "Data source= (LocalDb) \v11.0;i Nitial catalog=aspnet-mvcpro1-20141022154431;integrated Security=sspi; attachdbfilename=| Datadirectory|\aspnet-mvcpro1-20141022154431.mdf "Providername=" System.Data.SqlClient "/>--> <!--<add Name= "Hour1entities" connectionstring= "metadata=res://*/models.model1.csdl|res://*/models.model1.ssdl|res://*/ Models.model1.msl;provider=system.data.sqlclient;provider connection string= "Data source=.; Initial Catalog=hour1;user id=sa;password=123456; Multipleactiveresultsets=true; App=entityframework "" Providername= "System.Data.EntityClient"/> <add name= "hourentities" connectionstring= " Metadata=res://*/models.hour.csdl|res://*/models.hour.ssdl|res://*/models.hour.msl;provider= System.data.sqlclient;provider connection string= "Data source=.; Initial catalog=hour1;user id=sa;password=123456;multipleactiveresultsets=true;application name=EntityFramework "" ProvidernaMe= "System.Data.EntityClient"/>--> <add name= "complaintsysdbentities" connectionstring= "metadata=res://* /complaintsys.csdl|res://*/complaintsys.ssdl|res://*/complaintsys.msl;provider=system.data.sqlclient;provider Connection string= "Data source=114.80.154.68,32433;initial catalog=complaintsysdb;user id=sa;password=12344321; Multipleactiveresultsets=true; App=entityframework "" Providername= "System.Data.EntityClient"/> </connectionStrings>





ASP. NET project Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.