archive-gr.com » GR » D » DOTNETZONE.GR

Total: 987

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • Dot Net Rules : Δεκέμβριος 2013 - Δημοσιεύσεις
    concurrency CSS css3 data access layer databinding datasets DevExpress disconnected model DNN 7 0 dotnetnuke EF 5 0 Entity framework Entity Framework 6 0 enum support forms authentication general net host wcf HTML HTML 5 html5 IE8 Javascript jquery LINQ LINQ to Entities Linq to Sql LocalDB logging login controls master page master detail membership Mobile Views Model First MS Office objectdatasource performance Polymorphism SEO session state silverlight Sql Server Sql Server 2005 SQL Server 2008 sql server 2012 sqlcommand SQLDataReader stored procedures tables tips and tricks Tracing transaction log transactions UpdatePanel validation VB 2005 VB 2008 VB 9 0 ViewState Visual Basic 10 0 Visual Studio Visual Studio 2005 Visual Studio 2008 Visual Studio 2010 Visual Studio 2012 VS 2010 VS 2012 WCF wcf data service web server controls web service web config window forms windows forms WPF XAML XHTML XML XML Literals Πλοήγηση Αρχική σελίδα Εκδηλώσεις Ιστολόγια Συζητήσεις Εκθέσεις Φωτογραφιών Αρχειοθήκες Ιστορικό Δημοσιεύσεων Ιούνιος 2015 4 Μάρτιος 2015 2 Ιούνιος 2014 1 Δεκέμβριος 2013 2 Νοέμβριος 2013 14 Οκτώβριος 2013 2 Σεπτέμβριος 2013 5 Ιούλιος 2013 1 Ιανουάριος 2013 8 Δεκέμβριος 2012 11 Νοέμβριος 2012 3 Οκτώβριος 2012 12 Σεπτέμβριος 2012 16 Αύγουστος 2012 6 Ιούλιος 2012 13 Ιούνιος 2012 3 Μάιος 2012 4 Απρίλιος 2012 15 Μάρτιος 2012 8 Ιανουάριος 2012 3 Δεκέμβριος 2011 7 Νοέμβριος 2011 13 Οκτώβριος 2011 6 Σεπτέμβριος 2011 8 Αύγουστος 2011 6 Ιούλιος 2011 2 Μάιος 2011 1 Μάρτιος 2011 9 Φεβρουάριος 2011 15 Ιανουάριος 2011 14 Δεκέμβριος 2010 9 Νοέμβριος 2010 2 Οκτώβριος 2010 11 Σεπτέμβριος 2010 1 Αύγουστος 2010 3 Απρίλιος 2010 2 Μάρτιος 2010 5 Ιανουάριος 2010 1 Οκτώβριος 2009 2 Σεπτέμβριος 2009 4 Ιούνιος 2009 5 Απρίλιος 2009 1 Μάρτιος 2009 3 Φεβρουάριος 2009 2 Δεκέμβριος 2008 3 Νοέμβριος 2008 10 Σεπτέμβριος 2008 1 Αύγουστος 2008 1 Ιούλιος

    Original URL path: http://www.dotnetzone.gr/cs/blogs/dotnetrules/archive/2013/12.aspx (2015-07-15)
    Open archived version from archive


  • Dot Net Rules : Νοέμβριος 2013 - Δημοσιεύσεις
    SQL Server stored procedures and ownership chain Security is a big thing in SQL Server and can be implemented in various levels Διαβάστε περισσότερα Posted Πέμπτη 28 Νοεμβρίου 2013 9 23 μμ από το μέλος nikolaosk 0 σχόλια Tables with no clustered indexes or no indexes at all in SQL Server databases I have been delivering a certified course in MS SQL Server 2012 recently and I was asked a very interesting question If there is a way to find using T SQL tables in a database that have no clustered indexes or no indexes at all I have answered that Διαβάστε περισσότερα Posted Δευτέρα 18 Νοεμβρίου 2013 3 09 μμ από το μέλος nikolaosk 1 σχόλια Looking into SQL Server page types I have been delivering a certified course in MS SQL Server 2012 recently and I was asked a very interesting question about SQL Server pages and what types of pages exist I had to explain to them about SQL Server architecture first Each data file is Διαβάστε περισσότερα Posted Δευτέρα 18 Νοεμβρίου 2013 12 50 πμ από το μέλος nikolaosk 0 σχόλια Significance of order of columns in an index I have been delivering a certified course in MS SQL Server 2012 recently and I was asked a very interesting question Does the order of the column in an index matter Let s give some basic definitions first and make some analogies A single column index Διαβάστε περισσότερα Posted Κυριακή 17 Νοεμβρίου 2013 11 38 μμ από το μέλος nikolaosk 0 σχόλια SQL Server SET options and index creation I have been delivering a certified course in MS SQL Server 2012 recently and I have found something that was really impressive regarding SET options in SQL Server and index creation I will look into the SET QUOTED IDENTIFIER and SET ANSI NULLS options Διαβάστε περισσότερα Posted Κυριακή 17 Νοεμβρίου 2013 11 38 μμ από το μέλος nikolaosk 0 σχόλια Looking into the MERGE T SQL statement I have been delivering a certified course in MS SQL Server 2012 recently and I was asked to provide a demo about the MERGE statement I will provide you with a demo in this post trying to explain more about the MERGE T SQL statement and its use This Διαβάστε περισσότερα Posted Σάββατο 16 Νοεμβρίου 2013 3 11 πμ από το μέλος nikolaosk 0 σχόλια An introduction to Performance Monitor part 1 In my last SQL Server 2012 administration seminar I used Performance Monitor to analyse and troubleshoot issues regarding SQL Server It is built into Windows and many administrators used it a lot in the old days when some of the tools we have now in Διαβάστε περισσότερα Posted Παρασκευή 15 Νοεμβρίου 2013 1 23 πμ από το μέλος nikolaosk 0 σχόλια Looking into SQL Traces in SQL Server In this post I will talk about SQL Server Traces what they are and how we can use them An SQL Trace is a low level server side event inside SQL

    Original URL path: http://www.dotnetzone.gr/cs/blogs/dotnetrules/archive/2013/11.aspx (2015-07-15)
    Open archived version from archive

  • Dot Net Rules : Οκτώβριος 2013 - Δημοσιεύσεις
    Ιούλιος 2011 2 Μάιος 2011 1 Μάρτιος 2011 9 Φεβρουάριος 2011 15 Ιανουάριος 2011 14 Δεκέμβριος 2010 9 Νοέμβριος 2010 2 Οκτώβριος 2010 11 Σεπτέμβριος 2010 1 Αύγουστος 2010 3 Απρίλιος 2010 2 Μάρτιος 2010 5 Ιανουάριος 2010 1 Οκτώβριος 2009 2 Σεπτέμβριος 2009 4 Ιούνιος 2009 5 Απρίλιος 2009 1 Μάρτιος 2009 3 Φεβρουάριος 2009 2 Δεκέμβριος 2008 3 Νοέμβριος 2008 10 Σεπτέμβριος 2008 1 Αύγουστος 2008 1 Ιούλιος 2008 9 Ιούνιος 2008 10 Οκτώβριος 2013 Δημοσιεύσεις Localizing an ASP Net MVC 4 0 application In this post I will demonstrate with a hands on demo how to localise your ASP Net MVC applications The most important thing to point out is that in this world we live in we should expect our site to be visited by various people from different cultures and languages So we must be prepared to have our site internationalised Thankfully ASP Net MVC simplifies the whole internationalisation localisation process I would like to talk about the Thread CurrentCulture property that impacts formatting That means that this property instructs the runtime how it should display strings e g the currency in or or how the date should be displayed The other imporant property is Thread CurrentUICulture which is used by the Resource Manager to look up culture specific resources at run time I have installed VS 2012 Ultimate edition in my Windows 8 machine Υou can use Visual Studio Express 2012 for Web You can install Visual Studio Express 2012 for Web if you download Web Platform Installer You can download this tool from this link 1 I am launching VS 2012 and I will Visual C as the programming language I will also select ASP NET MVC 4 Web Application from the available templates Choose C as the development language and Internet Application I will name my application MvcLocalization All the necessary files are created 2 In the Ιndex chstml view in the Home folder add the following code var mysalary 2450 0m var birthday new DateTime 1980 2 17 div mysalary ToString c div br div birthday ToShortDateString div I just declare two variables and output them back to the screen I format the mysalary value as currency 3 Now we need to change our settings in the web config file In the system web section add globalization culture auto uiCulture auto 4 Build and run your application and you should will see something like the picture below My default culture in this machine is US English So everything is formatted accordingly I go to Internet Explorer I view my app in IE Tools Languages Set Language Preferences and add another language Greek Now I run again my application Now I see the new culture format is applied in both my strings Have a look at the picture below The way ASP Net runtime managed to display everything in the new culture because it identified the Accept Language HTTP Header and the globalization entry in the web config 5 Now let s

    Original URL path: http://www.dotnetzone.gr/cs/blogs/dotnetrules/archive/2013/10.aspx (2015-07-15)
    Open archived version from archive

  • Dot Net Rules : Σεπτέμβριος 2013 - Δημοσιεύσεις
    VS 2012 WCF wcf data service web server controls web service web config window forms windows forms WPF XAML XHTML XML XML Literals Πλοήγηση Αρχική σελίδα Εκδηλώσεις Ιστολόγια Συζητήσεις Εκθέσεις Φωτογραφιών Αρχειοθήκες Ιστορικό Δημοσιεύσεων Ιούνιος 2015 4 Μάρτιος 2015 2 Ιούνιος 2014 1 Δεκέμβριος 2013 2 Νοέμβριος 2013 14 Οκτώβριος 2013 2 Σεπτέμβριος 2013 5 Ιούλιος 2013 1 Ιανουάριος 2013 8 Δεκέμβριος 2012 11 Νοέμβριος 2012 3 Οκτώβριος 2012 12 Σεπτέμβριος 2012 16 Αύγουστος 2012 6 Ιούλιος 2012 13 Ιούνιος 2012 3 Μάιος 2012 4 Απρίλιος 2012 15 Μάρτιος 2012 8 Ιανουάριος 2012 3 Δεκέμβριος 2011 7 Νοέμβριος 2011 13 Οκτώβριος 2011 6 Σεπτέμβριος 2011 8 Αύγουστος 2011 6 Ιούλιος 2011 2 Μάιος 2011 1 Μάρτιος 2011 9 Φεβρουάριος 2011 15 Ιανουάριος 2011 14 Δεκέμβριος 2010 9 Νοέμβριος 2010 2 Οκτώβριος 2010 11 Σεπτέμβριος 2010 1 Αύγουστος 2010 3 Απρίλιος 2010 2 Μάρτιος 2010 5 Ιανουάριος 2010 1 Οκτώβριος 2009 2 Σεπτέμβριος 2009 4 Ιούνιος 2009 5 Απρίλιος 2009 1 Μάρτιος 2009 3 Φεβρουάριος 2009 2 Δεκέμβριος 2008 3 Νοέμβριος 2008 10 Σεπτέμβριος 2008 1 Αύγουστος 2008 1 Ιούλιος 2008 9 Ιούνιος 2008 10 Σεπτέμβριος 2013 Δημοσιεύσεις Looking into Fluent API in an ASP Net MVC 4 0 Code First application In this post I will demonstrate with a hands on example how to use the Fluent API to map POCO classes set configurations to SQL Server tables without using the set of conventions Entity Framework Code First expects I will also give a short introduction Διαβάστε περισσότερα Posted Κυριακή 29 Σεπτεμβρίου 2013 11 38 μμ από το μέλος nikolaosk 0 σχόλια An introduction into Glimpse and how to use it in your ASP Net applications In this post I will provide a short introduction to Glimpse and why i think it is very important for any developer that builds

    Original URL path: http://www.dotnetzone.gr/cs/blogs/dotnetrules/archive/2013/09.aspx (2015-07-15)
    Open archived version from archive

  • Dot Net Rules : Ιούλιος 2013 - Δημοσιεύσεις
    NET 4 0 ASP NET 4 5 ASP NET MVC ASP NET MVC 4 0 ASP NET Web Api ASPNETDB MDF ASPxGridView browser C c 3 0 c 4 0 C 3 0 caching client side Code First concurrency CSS css3 data access layer databinding datasets DevExpress disconnected model DNN 7 0 dotnetnuke EF 5 0 Entity framework Entity Framework 6 0 enum support forms authentication general net host wcf HTML HTML 5 html5 IE8 Javascript jquery LINQ LINQ to Entities Linq to Sql LocalDB logging login controls master page master detail membership Mobile Views Model First MS Office objectdatasource performance Polymorphism SEO session state silverlight Sql Server Sql Server 2005 SQL Server 2008 sql server 2012 sqlcommand SQLDataReader stored procedures tables tips and tricks Tracing transaction log transactions UpdatePanel validation VB 2005 VB 2008 VB 9 0 ViewState Visual Basic 10 0 Visual Studio Visual Studio 2005 Visual Studio 2008 Visual Studio 2010 Visual Studio 2012 VS 2010 VS 2012 WCF wcf data service web server controls web service web config window forms windows forms WPF XAML XHTML XML XML Literals Πλοήγηση Αρχική σελίδα Εκδηλώσεις Ιστολόγια Συζητήσεις Εκθέσεις Φωτογραφιών Αρχειοθήκες Ιστορικό Δημοσιεύσεων Ιούνιος 2015 4 Μάρτιος 2015 2 Ιούνιος 2014 1 Δεκέμβριος 2013 2 Νοέμβριος 2013 14 Οκτώβριος 2013 2 Σεπτέμβριος 2013 5 Ιούλιος 2013 1 Ιανουάριος 2013 8 Δεκέμβριος 2012 11 Νοέμβριος 2012 3 Οκτώβριος 2012 12 Σεπτέμβριος 2012 16 Αύγουστος 2012 6 Ιούλιος 2012 13 Ιούνιος 2012 3 Μάιος 2012 4 Απρίλιος 2012 15 Μάρτιος 2012 8 Ιανουάριος 2012 3 Δεκέμβριος 2011 7 Νοέμβριος 2011 13 Οκτώβριος 2011 6 Σεπτέμβριος 2011 8 Αύγουστος 2011 6 Ιούλιος 2011 2 Μάιος 2011 1 Μάρτιος 2011 9 Φεβρουάριος 2011 15 Ιανουάριος 2011 14 Δεκέμβριος 2010 9 Νοέμβριος 2010 2 Οκτώβριος 2010 11 Σεπτέμβριος 2010 1 Αύγουστος 2010 3 Απρίλιος 2010

    Original URL path: http://www.dotnetzone.gr/cs/blogs/dotnetrules/archive/2013/07.aspx (2015-07-15)
    Open archived version from archive

  • Dot Net Rules : Ιανουάριος 2013 - Δημοσιεύσεις
    want to learn more about it The individual object initializers are enclosed in braces and separated by commas Next I implement two simple methods GetPlayers returns a list of players GetFooballerById int id returns a single footballer by its ID public IEnumerable Footballer GetPlayers return footballers public Footballer GetFooballerById int id return footballers Find f f FootballerID id Next I am implementing the AddFootballer method which is pretty straightforward method If there is no item object we throw an exception If there is an item we give it a new ID and add the object to the collection public Footballer AddFootballer Footballer item if item null throw new ArgumentNullException item item FootballerID nextId footballers Add item return item Next I am implementing the RemoveFootballer method I just remove an object from the collection with a specific id public void RemoveFootballer int id footballers RemoveAll f f FootballerID id Finally I implement the UpdateFootballer method If there is no item object we throw an exception Then I find the index of the object in the collection array according to its ID and then remove it and add the new one public bool UpdateFootballer Footballer item if item null throw new ArgumentNullException item int index footballers FindIndex f f FootballerID item FootballerID if index 1 return false footballers RemoveAt index footballers Add item return true 4 Now we need to change the code we have written for our controller FootballerController cs in the Controllers folder Comment everything inside this class and just leave the code below public class FootballerController ApiController The complete implementation follows public class FootballerController ApiController static readonly IFootballerRepository repository new FootballerRepository public IEnumerable Footballer GetPlayers return repository GetPlayers public Footballer GetFooballerById int id var footballer repository GetFooballerById id if footballer null throw new HttpResponseException HttpStatusCode NotFound return footballer public HttpResponseMessage PostFootballer Footballer footballer footballer repository AddFootballer footballer var response Request CreateResponse Footballer HttpStatusCode Created footballer string uri Url Link DefaultApi new id footballer FootballerID response Headers Location new Uri uri return response public void PutFootballer int id Footballer footballer footballer FootballerID id if repository UpdateFootballer footballer throw new HttpResponseException HttpStatusCode NotFound public void DeleteFootballer int id Footballer footballer repository GetFooballerById id if footballer null throw new HttpResponseException HttpStatusCode NotFound repository RemoveFootballer id In ASP NET Web API a controller is a class that handles HTTP requests from the client Now I will explain what I have implemented in this class and what methods have been created I am adding a field that holds an IFootballerRepository instance static readonly IFootballerRepository repository new FootballerRepository This is the method to get a list of footballers Well nothing really to explain here public IEnumerable Footballer GetPlayers return repository GetPlayers This is the method to get a footballer item by id This method name also starts with Get This method has a parameter named id This parameter is mapped to the id segment of the URI path The method will throw an exception of type HttpResponseException if id is not valid This exception will be translated by Web API as a 404 Not Found error public Footballer GetFooballerById int id var footballer repository GetFooballerById id if footballer null throw new HttpResponseException HttpStatusCode NotFound return footballer Now I would like to explain again how the ASP NET Web API knows how to map URIs to our controller methods The ASP NET Web API framework for each HTTP message decides which controller receives the request by consulting a route table The Web API project contains a default route that you can find in the WebApiConfig cs file api controller id The controller and id are just placeholders controller is matched to the controller name controller in my case is footballer The HTTP request method is matched to the method name This rule applies only to GET POST PUT and DELETE requests api footballer will match the GetPlayers method api footballer 1 will match the GetFooballerById 1 method Next I am implementing the PostFootballer method This will create a new footballer item The new item is created when the client sends a HTTP POST request to the server with the new footballer object in body of the request message public HttpResponseMessage PostFootballer Footballer footballer footballer repository AddFootballer footballer var response Request CreateResponse Footballer HttpStatusCode Created footballer string uri Url Link DefaultApi new id footballer FootballerID response Headers Location new Uri uri return response The way POST requests are getting handled we define a method whose name starts with Post The method takes a parameter of type Footballer The clients to sends to the server a serialized representation of a footballer object using either XML or JSON for the serialization Next we must think of the response code The Web API framework sets the response status code to 200 OK HTTP 1 1 protocol dictated that when a POST request results in the creation of a resource the server should reply with status 201 Created When the server creates a resource it should include the URI of the new resource in the Location header of the response Next I am implementing the PutFootballer method This method will update a footballer item This method name starts with Put which makes the Web API to match it to PUT requests The method takes two parameters the footballer Id and the updated footballer object The id parameter is taken from the URI path and the footballer parameter is deserialized from the request body The ASP NET Web API framework takes simple parameter types from the route Complex types are taken from the request body public void PutFootballer int id Footballer footballer footballer FootballerID id if repository UpdateFootballer footballer throw new HttpResponseException HttpStatusCode NotFound Next I am implementing the DeleteFootballer method We define a method whose name starts with Delete so the Web API matches it to DELETE requests Τhe method has a parameter named id This parameter is mapped to the id segment of the URI path Ιf the footballer object is not found an exception is thrown If the deletion is successful then status code 204 No Content will be returned public void DeleteFootballer int id Footballer footballer repository GetFooballerById id if footballer null throw new HttpResponseException HttpStatusCode NotFound repository RemoveFootballer id In the next and final post in this series I will build the Index cshtml using Knockout which is a JavaScript library that helps developers to create rich responsive displays when a clean underlying data model exists I think that this is enough material for one post and before I implement Index cshtml I must introduce Knockout library to you Hope it helps Posted Σάββατο 12 Ιανουαρίου 2013 5 52 μμ από nikolaosk 0 σχόλια Δημοσίευση στην κατηγορία asp net C Entity framework jquery Code First Visual Studio 2012 ASP NET MVC 4 0 ASP NET Web Api Looking into the ASP Net Web API part 1 In this post I would like to show you a hands on example on ASP Net Web API by building a small ASP Net application I am going to build an ASP Net MVC 4 0 Web application to create a Web API that returns a list of football players I will also use the popular Javascript library JQuery to issue requests to the server In the second part of this blog post I will show you how to support more operations in an HTTP service like create update delete players using a REST architectural style Before I go on with the actual example I will talk a little bit about REST In 2000 Roy Fielding introduced REpresentational State Transfer in his P H D Thesis It describes a scalable architecture for building services that build on HTTP REST is fundamentally different from SOAP SOAP defines a transport neutral model that is focused on defining custom services contracts with custom operations You can invoke those operations over a variety of different transports using different message encodings REST defines a transport specific HTTP model focused on resources In REST we build services around a uniform interface and common data formats HTTP methods are GET POST PUT DELETE also known as verbs Data formats supported in REST inculde HTML XML JSON REST is also known as a Resource Orientated Architecture The main focus is on identifying and naming resources URIs We also focus on how to represent them XML Format We use uniform interface to interact with those URIs through HTTP verbs GET POST PUT DELETE Through this model we can achieve interoperability and scalability for our applications Web API is a fully extensible framework for building HTTP based endpoints on top of ASP Net It was released with ASP Net MVC 4 0 It is based on ASP Net Routing and but is not linked only to ASP Net MVC You can use it in a Web Forms project as well You can download it through NuGet so you can have the latest version The most important thing right now is to download and install all the tools libary software in your computer so you can follow along You can download all the necessary software tools Visual Studio 2012 Web Edition along with a web server a Sql Server instance libraries binaries if you download Web Platform Installer You can download this tool from this link After you install it you must search for Visual Studio Express 2012 for Web Have a look at the picture below Then click Add and then Install Everything you need will be installed Maybe you need to reboot the machine so do not worry if you will have to do this I have installed Visual Studio 2012 Ultimate edition in my machine which is Windows 8 by the way I have also installed the latest version of Net Framework and I will show you later how to download more libraries when needed I have installed SQL Server 2012 Enterprise Edition in my machine As a Microsoft Certified Trainer I have access to this software but as explained earlier you need only to download Web Platform Installer and then download the Visual Studio Express 2012 for Web and install it Let s start building our ASP Net MVC 4 0 Web application 1 I am launching VS 2012 and I will Visual C as the programming language I will also select ASP NET MVC 4 Web Application from the available templates Have a look at the picture below I have named my application WebApi and then clicked OK 2 From the available templates in the next screen I select Web API This template will create all the necessary files in order to build the application Click OK Have a look at the picture below 3 Have a look at the Solution Explorer to get a feeling of the files being created and the structure of the web application Have a look at the picture below 4 Now we need to add a model that will basically be the data in our application The way everything works is the following We will pass a request to the server an HTTP request message to the server then the server will respond with an HTTP response serializing the model to JSON or XML or any other format On the client side serialized data can be parsed and deserialized Most clients can parse XML and JSON Have a look at the picture below to see the how I add a new model to my application I simply add a class file to my model in the Models folder I name the class Footballer cs The code follows public class Footballer public int FootballerID get set public string FirstName get set public string LastName get set public double Weight get set public double Height get set public DateTime JoinedClub get set public string PositionPlayed get set public int GoalsScored get set 5 We need to add a new controller that basically will handle the HTTP request Add a new controller as follows In Solution Explorer right click the the Controllers folder Select Add and then select Controller Have a look at the picture below In the Add Controller wizard name the controller FootballerController In the Template drop down list select Empty API Controller Then click Add The FootballerController will inherit from the ApiController class and not the Controller class I will add the following methods to the class public class FootballerController ApiController Footballer footballers new Footballer new Footballer FootballerID 1 FirstName Steven LastName Gerrard Height 1 85 Weight 85 JoinedClub DateTime Parse 12 12 1999 PositionPlayed Attacking Midfielder GoalsScored 23 new Footballer FootballerID 2 FirstName Jamie LastName Garragher Height 1 89 Weight 89 JoinedClub DateTime Parse 12 02 2000 PositionPlayed Central Defender GoalsScored 2 new Footballer FootballerID 3 FirstName Luis LastName Suarez Height 1 72 Weight 73 JoinedClub DateTime Parse 12 01 2012 PositionPlayed Striker GoalsScored 27 public IEnumerable Footballer GetPlayers return footballers public Footballer GetFooballerById int id var footballer footballers FirstOrDefault f f FootballerID id if footballer null throw new HttpResponseException HttpStatusCode NotFound return footballer public IEnumerable Footballer GetFooballersByPosition string position return footballers Where f string Equals f PositionPlayed position StringComparison OrdinalIgnoreCase All my data is stored in an array in memory We have 3 methods that return data and not view inside the controller class GetPlayers returns a list of players GetFooballerById int id returns a single footballer by its ID GetFooballersByPosition string position returns all football players according to their playing position Each method on the controller will map to a URI The client in this case the web browser will send an HTTP GET request to the URI 6 Build and run you application The IIS Express will start and a notification will appear in the bottom corner of the screen showing the port number that it is running under A random port number will be selected You will see the default page In my case is http localhost 57865 Now I must invoke the web API so must use the following URI http localhost 57865 api footballer Have a look below to see what I see when I view the page in Firefox It is displayed in XML in the browser 7 Now we need to test the other two methods The first one will return a footballer by ID and the second one will return data based on the player s playing position While my application is still running I type in the browser http localhost 57865 api footballer 1 and hit enter Have a look at the picture below to see the results I get in Firefox While my application is still running I type in the browser http localhost 57865 api footballer position Attacking 20Midfielder and hit enter Have a look at the picture below to see the results I get in Firefox 8 I will write a small client application a javascript client in order to consume the APIs I will modify the Index cshtml file in the Views folder I will not be using Razor in this post I will only use plain HTML 5 and Javascript The contents of the Index chstml follow DOCTYPE html html lang en head title ASP NET Web API title link href Content Site css rel stylesheet script src Scripts jquery 1 7 1 min js type text javascript script script type text javascript document ready function getJSON api footballer function data each data function key val var str val FirstName val LastName li text str appendTo footballers script head body id body div class main div h1 All Footballers h1 ul id footballers div div label for FootballerId ID label input type text id FootballerId size 5 input type button value Search onclick find p id footballer div div body html Let me explain what I am doing here There is a link to JQuery library at the top of the script I have an HTML 5 markup where I will present the footballers eventually With the command below I am sending an Ajax request to the server The getJSON command does that The response will be an array of JSON objects When the request successfully completes see code below each data function key val var str val FirstName val LastName li text str appendTo footballers getJSON api footballer the data will be returned formatted When I build and run the application this is what I get My application works I can see what actually is going on behind the scenes if I have the right tool Fiddler is a web debugging proxy tool and you can use it to see all useful information the clients and servers exchange You can download Fiddler here In my case I am mostly interested in the JSON objects returned from the server Have a look at the picture below 9 Now I will show you how to find a footballer by id The code for the find method is function find var id FootballerId val getJSON api footballer id function data var str data FirstName data LastName footballer text str fail function jqXHR textStatus err footballer text Error err We make a call to the jQuery getJSON function to send the AJAX request We use the ID to construct the request URI The response from this request is a JSON representation of a single Footballer object Have a look at the picture below If I enter an invalid ID in the search box then I get back an HTTP error Have a look at the picture below Now I need to explain how the ASP NET Web API knows how to map URIs to our controller methods The ASP NET Web API framework for each HTTP message decides which controller receives the request by consulting a route table The Web API project contains a default route that you can find in the WebApiConfig cs file api controller id The controller and id are just placeholders controller is matched to the controller name controller in my case is footballer The HTTP request method is matched to the method name

    Original URL path: http://www.dotnetzone.gr/cs/blogs/dotnetrules/archive/2013/01.aspx (2015-07-15)
    Open archived version from archive

  • Dot Net Rules : Δεκέμβριος 2012 - Δημοσιεύσεις
    not DeleteConfirmed AcceptVerbs HttpPost HttpGet represent attributes that specify which HTTP verbs Get Post an action method will respond to In the example above we have an HTTP Post HttpPost ActionName Delete The final topic I would like to talk about is Action Filters They are applied to methods and classes in the form of attributes An ActionFilter provides some methods that are run before and after request and response processing Some of them are OutputCache which caches the output of the controller Authorize that restricts an action to authorized users or roles If I open the MovieController cs file and then apply the Authorize see below to the Index method private MovieDBContext db new MovieDBContext GET Movie Authorize public ActionResult Index return View db Movies ToList and then navigate to the http localhost 59871 movie this is what I will get the following as a result redirect to the login page The ASP Net MVC runtime will pick up the Authorize attribute and redirect me to the Login page Hope you have followed along and mastered the topics presented here as they are absolutely necessary for building ASP Net MVC applications In the next post we will continue building our application Hope it helps Posted Κυριακή 30 Δεκεμβρίου 2012 11 37 μμ από nikolaosk 0 σχόλια Δημοσίευση στην κατηγορία asp net C CSS Entity framework jquery HTML Code First Visual Studio 2012 ASP NET MVC 4 0 Creating a complete ASP Net MVC 4 0 application with Visual Studio 2012 C EF 5 0 Code First part 3 I have decided to write a series of posts on how to write a small ASP Net MVC 4 0 application I will develop this application step by step and I will explain everything that you need to know in order to develop ASP Net MVC 4 0 applications This is the third post in this series You can find the first one here and the second one here Make sure you read and understand the first post and the second post As I design and develop the application I will explain some of the most common building blocks of ASP Net MVC like Code blocks Code expressions Action Results Action Selectors Action Filters Layout Views and Partial Views Now we have to think about the data access technology that we will use in our sample application I am going to build an ASP Net MVC application where users can search through a collection of movies and rate them I will not use traditional ADO Net data access techniques I will use Entity Framework EF which is part of the Net framework Obviously I cannot go into much detail on what EF is and what it does I will give again a short introduction The Net framework provides support for Object Relational Mapping through EF So EF is a an ORM tool and it is now the main data access technology that microsoft works on I use it quite extensively in my projects Through EF we have many things out of the box provided for us We have the automatic generation of SQL code It maps relational data to strongly types objects All the changes made to the objects in the memory are persisted in a transactional way back to the data store You can search in my blog because I have posted many posts regarding ASP Net and EF There are different approaches paradigms available using the Entity Framework namely Database First Code First Model First You can find in this post an example on how to use the Entity Framework to retrieve data from an SQL Server Database using the Database Schema First approach In this approach we make all the changes at the database level and then we update the model with those changes In this post you can see an example on how to use the Model First approach when working with ASP Net and the Entity Framework This model was firstly introduced in EF version 4 0 and we could start with a blank model and then create a database from that model When we made changes to the model we could recreate the database from the new model The Code First approach is the more code centric than the other two Basically we write POCO classes and then we persist to a database using something called DBContext In this application we will us the Code First approach when building our data centric application with EF Code First relies on DbContext We create 2 3 classes e g Movie Review with properties and then these classes interact with the DbContext class Then we can create a new database based upon our POCOS classes and have tables generated from those classes We do not have an edmx file in this approach By using this approach we can write much easier unit tests DbContext is a new context class and is smaller lightweight wrapper for the main context class which is ObjectContext Schema First and Model First When building an application the most important thing is to understand the domain and the domain business objects These should be the objects that should drive the application and not e g the database schema So I like to design my entities very carefully and 1 Launch Visual Studio and open your application 2 We will add the 2 entities I am going to show you below in the Models folder Add a new class file named Movie cs inside the Models folder The Movie cs entity is as follows public class Μovie public int Id get set public string Name get set public string Director get set public DateTime YearReleased get set public ICollection MovieReview Reviews get set We have added some properties in this entity Now we need to add the MovieReview entity Add a new class file named MovieReview cs inside the Models folder The MovieReview cs entity is as follows public class MovieReview public int Id get set public int Rating get set public string Comment get set public int MovieId get set So we have our entities ready We have one movie and many reviews That should be clear by now I will instantiate these objects store them and retrieve them in my database My database will be an SQL Server database where I will create from the entities Then we need to create a context class that inherits from DbContext Add a new class to the Models folder Name it MovieDBContext cs Now that we have the entity classes created we must let the model know I will have to use the DbSet T property The code for this class follows public class MovieDBContext DbContext public DbSet Μovie Movies get set public DbSet MovieReview Reviews get set The MovieDBContext is a database context class This class is responsible for talking to the underlying database storing and updating the data to the database We need to add this reference to the file using System Data Entity Now we need to create the connection string The only place we can do that is by opening the web config file and adding the following lines of code inside the connectionStrings section connectionStrings add name FootballerDBContext connectionString Data Source LocalDb v11 0 AttachDbFilename DataDirectory MovieReviews mdf Integrated Security True providerName System Data SqlClient connectionStrings 3 Now we need to access our model from a controller This is going to be a simple class that retrieves the footballers data Right click the Controllers folder and create a new MovieController controller Have a look at the picture below to set the appropriate settings and then click Add Visual Studio will create the following A MovieController cs file in the project s Controllers folder A Movie folder in the project s Views folder Create cshtml Delete cshtml Details cshtml Edit cshtml and Index cshtml in the new Views Footballer folder Have a look at the picture below The ASP NET MVC 4 framework automatically creates the CRUD create read update and delete action methods and views This is know as scaffolding We have a fully functional web application that lets you create list edit and delete records 4 Build and run your application Navigate to the localhost youport movie Have a look at the picture below I will create two entries for two of my favorite movies The Godfather Raging Bull I click on the Create New link and insert the data Finally I click Create The data is saved in the database I know exactly what you are thinking right now You did not create any database Entity Framework Code First created the database for us EF detected that the database connection string provided pointing to a database didn t exist so Code First created the database automatically Have a look at the picture below Make sure you add your entries to the database through the view We have created two new records and stored it in the database Click the Edit Details and Delete links We have all this functionality out of the box through the magic of scaffolding I urge you to have a look place breakpoints as well in the MovieController cs class file and notice the flow of the execution We pass a strongly typed object Movie to the various views Have a look again in the views inside the Views Movie folder In the Create cshtml Delete cshtml Details cshtml Edit cshtml and Index cshtml Views at the beginning of these files you will see this line of code model MovieReviews Models Μovie By adding a model statement at the top of the view file we tell the view the type of object that the view should rende r This is how we pass a model through a controller to the appropriate view I am sure you can clearly see the separation of concerns 5 Now we can see our database and the data that was saved We go to View Server Explorer or Database Explorer and connect to the instance of SQL Server Have a a look at the picture below to see what I mean Click OK Have a look at the picture below to see the database and the tables Now I can see the data that was inserted through my ASP Net MVC application to the database I am sure you know have a feeling about the application we are about to build I will explain more about ASP Net MVC as we go on building the application Hope it helps Posted Κυριακή 30 Δεκεμβρίου 2012 5 35 μμ από nikolaosk 0 σχόλια Δημοσίευση στην κατηγορία asp net C CSS Entity framework jquery HTML Code First Visual Studio 2012 ASP NET MVC 4 0 Creating a complete ASP Net MVC 4 0 application with Visual Studio 2012 C EF 5 0 Code First part 2 I have decided to write a series of posts on how to write a small ASP Net MVC 4 0 application I will develop this application step by step and I will explain everything that you need to know in order to develop ASP Net MVC 4 0 applications This is the second posts in this series You can find the first one here Make sure you read and understand the first post In this post I would like to look into the internals of ASP Net MVC and what happens when an incoming HTTP request comes in from the browser Bear in mind that the local web server is IIS Express This is the web server that will handle the incoming request IIS Express will take that request and deliver it to my application Let s run our application again and click on the Contact link on the top right hand corner of the page When I click that link the URL in my browser becomes http localhost 59871 Home Contact As mentioned earlier the local web server will take this request and deliver it to my ASP Net MVC application Inside the ASP Net MVC application there is a Routing Engine that takes requests and delivers them to the proper component In this case the request will end up in the HomeController cs class file Remember that the Controller is the component in the MVC pattern that orchestrates everything A request for Home Something will always come to the HomeController cs class A request in our case http localhost 59871 Home Contact will end up in the Contact method inside the HomeController cs class file Have a look at the picture below I am sure you can see the naming conventions applied here This action method public ActionResult Contact does not do anything else but to return a View No Model is build on this occasion So how can we reach the appropriate view to display There are more naming conventions Τhe ASP Net MVC application will look in the Views Folder and then in the Home folder The name Home matches the name of the Home controller and then it will pick the Contact cshtml Inside this view there is all the markup that is rendered by the browser Have a look at the picture below I would like to explain a bit more the ViewBag property The ViewBag allows data to be added to it which is then available in the View It is similar to how a session variable works when you assign a value to a ViewBag property such as ViewBag Have a look at the HomeController cs file and the Contact method It passes the ViewBag Message Your contact page to the Contact View Open the Contact cshtml file in the Solution Explorer hgroup class title h1 ViewBag Title h1 h2 ViewBag Message h2 hgroup As you can see in the bold line above this is the way we get the contents of the ViewBag Message in the our view Let s add another ViewBag property Have a look at the code below public ActionResult Contact ViewBag Message Your contact page ViewBag AdminEmail admin example com return View I have added ViewBag AdminEmail to the Contact method Now I am going to retrieve the value inside the ViewBag AdminEmail from the Contact cshtml view p span class label WebMaster span span a href mailto ViewBag AdminEmail ViewBag AdminEmail a span p Obviously this is not the best way to pass data from our controller to the View Let s add a model to our application In the Models folder add a new class file and name it ContactModel cs The contents of this class follow namespace MovieReviews Models public class ContactModel public string Name get set public string Surname get set public string Email get set I add three properties in my class Now I need to change the code inside the Contact method in the HomeController cs class This is how Contact method looks now public ActionResult Contact ViewBag Message Your contact page ViewBag AdminEmail admin example com var contact new ContactModel contact Name Nick contact Surname kantzelis contact Email nikolaosk admin com return View contact With this line of code return View contact we say that we want to pass this model contact to the appropriate View We need to modify the Contact cshtml view p span class label Name Model Name span br span class label Surname Model Surname span br span class label Email Model Email span p We use the Model property represents the model object ContactModel object passed to the view This is a strongly typed property as opposed to the ViewBag In the beginning of the Contact cshtml we must add this line of code model MovieReviews Models ContactModel By this line of code I inform the View about the model and what kind of model ContactModel object it has The razor engine now knows how to display this information to the user We just have to place the Model property in the appropriate place in the View Now when I run the application I see the following results Hope all makes sense now I mean how the MVC pattern works and what the Controller Model and the View do I know that we have not build the actual application yet We will do that step by step in the next posts but it is of vital significance to understand the basic components of the MVC pattern and its internals Hope it helps Posted Σάββατο 29 Δεκεμβρίου 2012 3 31 μμ από nikolaosk 0 σχόλια Δημοσίευση στην κατηγορία asp net C CSS Entity framework jquery HTML Code First Visual Studio 2012 ASP NET MVC 4 0 Creating a complete ASP Net MVC 4 0 application with Visual Studio 2012 C EF 5 0 Code First part 1 I have been using ASP Net MVC Visual Studio C Entity Framework JQuery CSS to build web sites and applications I have been teaching ASP Net MVC to people from all walks of life with different experience in Web development I have decided to write a series of posts on how to write a small ASP Net MVC 4 0 application I will develop this application step by step and I will explain everything that you need to know in order to develop ASP Net MVC 4 0 applications There are some other posts in my blog regarding ASP Net MVC You can find them here here Please have a look at those posts to get a feeling for ASP Net MVC I will repeat some of the content found in those posts in the posts that will be part of this series If you are an experienced ASP NET MVC developer maybe you mus go on and read something more advanced I will talk about advanced things later on though This series is aimed at developers that start learning ASP Net MVC I assume that you have some working knowledge of HTML CSS It will be great if you programmed before with C or used Visual Studio Αs I said earlier I will try to explain everything in detail so beginners can benefit from that I am going to build a web application where users can post reviews about movies The user can list the reviews edit the reviews and obviously create a review The administrator will be able to post movies so other users can review it Users can also search for movies to review This is the general overview of the application I will explain more about the application as we move on I will also show you how to deploy the application to IIS and Windows Azure towards the end The most important thing right now is to download and install all the tools libary software in your computer so you can follow along You can download all the necessary software tools Visual Studio 2012 Web Edition along with a web server a Sql Server instance libraries binaries if you download Web Platform Installer You can download this tool from this link After you install it you must search for Visual Studio Express 2012 for Web Have a look at the picture below Then click Add and then Install Everything you need will be installed Maybe you need to reboot the machine so do not worry if you will have to do this So now you have an IDE Visual Studio 2012 that you can write test and debug your code SQL Server is also installed We need SQL Server to persist our data back to the database A lightweight web server IIS Express is also installed so it can execute host our web application our code during development I have installed Visual Studio 2012 Ultimate edition in my machine which is Windows 8 by the way I have also installed the latest version of Net Framework and I will show you later how to download more libraries when needed I have installed SQL Server 2012 Enterprise Edition in my machine As a Microsoft Certified Trainer I have access to this software but as explained earlier you need only to download Web Platform Installer and then download the Visual Studio Express 2012 for Web and install it Before we move on to the actual hands on demo I would like to say a few words on how I understand ASP Net MVC and what its main benefits design goals are Obviously the first paradigm on bulding web applications on the web is Web Forms Web forms was the first and only way to build web application when ASP Net was introduced to the world ten years ago It replaced the classic ASP model by providing us with a strongly typed code that replaced scripting We had have languages that are compiled Web forms feels like a form that you programmed with VB 6 0 for the desktop The main idea was to abstract the WEB By that I mean HTML is abstracted in a way Click events replaced Post operations Since that time web standards have strengthened and client side programming is on the rise Developers wanted to have more control on the HTML Web forms as I said before handles HTML in an abstract way and is not the best paradigm for allowing full control on the HTML rendering ASP Net MVC provide us with a new way of writing ASP Net applications It does not replace Web Forms It is just an alternative project type It still runs on ASP Net and supports caching sesions and master pages In ASP Net MVC applications we have no viewstate or page lifecycle For more information on understanding the MVC application execution process have a look at this link It is a highly extensible and testable model In order to see what features of ASP Net are compatible in both Models have a look here MVC pattern has been around for decades and it has been used across many technologies as a design pattern to use when building UI It is based on an architecture model that embraces the so called seperation of concern pattern There are three main building blocks in the MVC pattern The View talks to the Model The Model has the data that the View needs to display The View does not have much logic in them at all The Controller orchestrates everything When we have an HTTP request coming in that request is routed to the Controller It is up to the Controller to talk to the file system database and build the mode l The routing mechanism in MVC is implemented through the System Web Routing assembly Routes are defined during application startup Have a look at the Global asax file when building an MVC application The Controller will select which View to use to display the Model to the client It is clear that we have now a model that fully supports seperation of concerns The Controller is responsible for building the Model and selecting the View The Controller does not save any data or state The Model is responsible for that The Controller selects the View but has nothing to do with displaying data to the client This is the View s job The Controller component is basically a class file that we can write VB Net or C code We do not have Page Load event handler routines just simple methods which are easy to test No code behind files are associated with the Controller classes All these classes should be under the Controllers folder in your application Controller type name must end with Controller e g ProductController In the Views folder we should place the files responsible for displaying content to the client Create subfolders for every Controller Shared folder contains views used by multiple controllers In this post I will use the Razor View engine rather than the WebForms View Razor View engine is designed with MVC in mind and it is the way as far as I am concerned to work with ASP Net MVC ASP Net MVC does not dictate what kind of data access architecture we will use in our application It does not also dictate how to build our business layer domain classes and objects Finally ASP Net MVC is very extensible and easy to test Let s start building our web application 1 I am launching VS 2012 and I will Visual C as the programming language I will also select ASP NET MVC 4 Web Application from the available templates Have a look at the picture below I have named my application MovieReviews and then clicked OK 2 From the available templates in the next screen I select Internet Application This template will create all the necessary files in order to build the application Click OK Have a look at the picture below 3 Have a look at the Solution Explorer to get a feeling of the files being created and the structure of the web application Have a look at the picture below 4 Now we can build and run the application You can do that by pressing F5 in the Visual Studio IDE Have a look at the picture below to see the homepage of the web application Now we can right click View Page Source to see the pure HTML 5 code Have a look at the picture below You can also see that there is ViewPort meta tag and this is very important for mobile devices With this tag we tell the mobile browser that our site will adapt to the width of the device There also links to Javascript and CSS files There is a link to the modernizer library This Javascript library makes sure our site works with older browsers before HTML 5 existed So far we have talked about MVC pattern We have talked about the application we want to build I have explained what kind of tools we need and how to get them Finally we have created our sample ASP Net MVC application The template we have chosen Internet Application provides us with all the necessary files in order to have a working ASP Net MVC application out of the box Hope it helps Posted Σάββατο 29 Δεκεμβρίου 2012 1 37 πμ από nikolaosk 0 σχόλια Δημοσίευση στην κατηγορία asp net C CSS Entity framework jquery HTML Code First Visual Studio 2012 ASP NET MVC 4 0 Looking into the DBCC LOGINFO and DBCC SQLPERF commands In this post I would like to talk a bit about Transaction Log its various parts and its architecture I will not go into details about what Transaction Log is because it is well documented elsewhere I would like also to highlight a few important points Διαβάστε περισσότερα Posted Σάββατο 29 Δεκεμβρίου 2012 12 19 πμ από το μέλος nikolaosk 0 σχόλια Δημοσίευση στην κατηγορία SQL Server 2008 Sql Server 2005 Sql Server transaction log sql server 2012 dbcc commands Looking into CSS3 Multiple backgrounds In this post I will be looking into a great feature in CSS3 called multiple backgrounds With CSS3 ourselves as web designers we can specify multiple background images for box elements using nothing more than a simple comma separated list This is a very nice feature that can be useful in many websites In this hands on example I will be using Expression Web 4 0 This application is not a free application You can use any HTML editor you like You can use Visual Studio 2012 Express edition You can download it here Before I go on with the actual demo I will use the http www caniuse com to see the support for CSS 3 Multiple backgrounds from the latest versions of modern browsers Please have a look in this link All modern browsers support this feature I am typing this very simple HTML 5 markup with an internal CSS style DOCTYPE html html lang en head title Sold items title style box border 1px solid afafaf width 260px height 290px background image url shirt png url sold jpg background position center bottom right top background repeat no repeat no repeat style head body header h1 CSS3 Multiple backgrounds h1 header div id box div footer p All Rights Reserved p footer body html Let me explain what I do here multiple background images are specified using a comma separated list of values for the background image property A comma separated list is also used for the other background properties such as background repeat background position So in the next three lines of CSS code background image url shirt png url sold jpg background position center bottom right top background repeat no repeat no repeat we have 2 images placed in the div element The first is placed center bottom in the div element and the second is placed at right top position inside the div element Both images do not get repeated I view the page in IE 10 and all the latest versions of Opera Chrome and Firefox Have a look at the picture below Hope it helps Posted Τετάρτη 19 Δεκεμβρίου 2012 2 46 πμ από nikolaosk 0 σχόλια Δημοσίευση στην κατηγορία asp net HTML 5 CSS3 multiple backgrounds CSS 3 Looking into the jQuery LazyLoad Plugin I have been using JQuery for a couple of years now and it has helped me to solve many problems on the client side of web development You can find all my posts about JQuery in this link In this post I will be providing you with a hands on example on the JQuery LazyLoad Plugin If you want you can have a look at this post where I describe the JQuery Cycle Plugin You can find another post of mine talking about the JQuery Carousel Lite Plugin here Another post of mine regarding the JQuery Image Zoom Plugin can be found here You can have a look at the JQuery Overlays Plugin here There are times when when I am asked to create a very long page with lots of images My first thought is to enable paging on the proposed page Imagine that we have 60 images on a page There are performance concerns when we have so many images on a page Paging can solve that problem if I am allowed to place only 5 images on a page Sometimes the customer does not like the idea of the paging Believe it or not some people find the idea of paging not attractive at all In that case I need a way to only load the initial set of images and as the user scrolls down the page to load the rest So as someone scrolls down new requests are made to the server and more images are fetched I can accomplish that with the jQuery LazyLoad Plugin This is just a plugin that delays loading of images in long web pages The images that are outside of the viewport visible part of web page won t be loaded before the user scrolls to them Using jQuery LazyLoad Plugin on long web pages containing many large images makes the page load faster In this hands on example I will be using Expression Web 4 0 This application is not a free application You can use any HTML editor you like You can use Visual Studio 2012 Express edition You can download it here You can download this plugin from this link I launch Expression Web 4 0 and then I type the following HTML markup I am using HTML 5 DOCTYPE html html lang en head title Liverpool Legends title script type text javascript src jquery 1 8 3 min js script script type text javascript src jquery lazyload min js script head body header h1 Liverpool Legends h1 header div id main img src barnes JPG width 800 height 1100 p img src dalglish JPG width 800 height 1100 p img class LiverpoolImage src loader gif data original fans JPG width 1200 height 900 p img class LiverpoolImage src loader gif data original lfc JPG width 1000 height 700 p img class LiverpoolImage src loader gif data original Liverpool players JPG width 1100 height 900 p img class LiverpoolImage src loader gif data original steven gerrard JPG width 1110 height 1000 p img class LiverpoolImage src loader gif data original robbie JPG width 1200 height 1000 p div footer p All Rights Reserved p footer script type text javascript function img LiverpoolImage lazyload script body html This is a very simple markup I have added references to the JQuery library current version is 1 8 3 and the JQuery LazyLoad Plugin Firstly I add two images img src barnes JPG width 800 height 1100 p img src dalglish JPG width 800 height 1100 p that will load immediately as soon as the page loads Then I add the images that will not load unless they become active in the viewport I have all my img tags pointing the src attribute towards a placeholder image I m using a blank 1 1 px grey image loader gif The five images that will load as the user scrolls down the page follow img class LiverpoolImage src loader gif data original fans JPG width 1200 height 900 p img class LiverpoolImage src loader gif data original lfc JPG width 1000 height 700 p img class LiverpoolImage src loader gif data original Liverpool players JPG width 1100 height 900 p img class LiverpoolImage src loader gif data original steven gerrard JPG width 1110 height 1000 p img class LiverpoolImage src loader gif data original robbie JPG width 1200 height 1000 p Then we need to rename the image src to point towards the proper image placeholder The full image URL goes into the data original attribute The Javascript code that makes it all happen follows We need to make a call to the JQuery LazyLoad Plugin We add the script just before we close the body element script type text javascript function img LiverpoolImage lazyload script We can change the code above to incorporate some effects script type text javascript img LiverpoolImage lazyload effect fadeIn script That is all I need to write to achieve lazy loading It it true that you can do so much with less I view my simple page in Internet Explorer 10 and it works as expected I have tested this simple solution in all major browsers and it works fine You can test it yourself and see the results in your favorite browser Hope it helps Posted Τρίτη 18 Δεκεμβρίου 2012 7 48 μμ από nikolaosk 0 σχόλια Δημοσίευση στην κατηγορία asp net jquery HTML 5 Jquery LazyLoad Plugin Looking into the JQuery Overlays Plugin I have been using JQuery for a couple of years now and it has helped me to solve many problems on the client side of web development You can find all my posts about JQuery in this link In this post I will be providing you with a hands on example on the JQuery Overlays Plugin If you want you can have a look at this post where I describe the JQuery Cycle Plugin You can find another post of mine talking about the JQuery Carousel Lite Plugin here Another post of mine regarding the JQuery Image Zoom Plugin can be found here I will be writing more posts regarding the most commonly used JQuery Plugins With the JQuery Overlays Plugin we can provide the user overlay with more information about an image when the user hovers over the image I have been using extensively this plugin in my websites In this hands on example I will be using Expression Web 4 0 This application is not a free application You can use any HTML editor you like You can use Visual Studio 2012 Express edition You can download it here You can download this plugin from this link I launch Expression Web 4 0 and then I type the following HTML markup

    Original URL path: http://www.dotnetzone.gr/cs/blogs/dotnetrules/archive/2012/12.aspx (2015-07-15)
    Open archived version from archive

  • Dot Net Rules : Νοέμβριος 2012 - Δημοσιεύσεις
    out if indeed EF version is 5 0 version is installed have a look at the References Have a look at the picture below to see what you will see if you have installed everything correctly Have a look at the picture below 6 Then we need to create a context class that inherits from DbContext Add a new class to the CodeFirst folder Name it FootballerDBContext Now that we have the entity classes created we must let the model know I will have to use the DbSet T property The code for this class follows public class FootballerDBContext DbContext public DbSet Footballer Footballers get set Do not forget to add using System Data Entity in the beginning of the class file 7 We must take care of the connection string It is very easy to create one in the web config It does not matter that we do not have a database yet When we run the DbContext and query against it it will use a connection string in the web config and will create the database based on the classes I will use the name FootballTraining for the database In my case the connection string inside the web config looks like this connectionStrings add name CodeFirstDBContext connectionString server integrated security true database FootballTraining providerName System Data SqlClient connectionStrings 8 Now it is time to create Linq to Entities queries to retrieve data from the database Add a new class to your application in the CodeFirst folder Name the file DALfootballer cs We will create a simple public method to retrieve the footballers The code for the class follows public class DALfootballer FootballerDBContext ctx new FootballerDBContext public List Footballer GetFootballers var query from player in ctx Footballers select player return query ToList 9 Place a GridView control on the Default aspx page and leave the default name Add an ObjectDataSource control on the Default aspx page and leave the default name Set the DatasourceID property of the GridView control to the ID of the ObjectDataSource control DataSourceID ObjectDataSource1 Let s configure the ObjectDataSource control Click on the smart tag item of the ObjectDataSource control and select Configure Data Source In the Wizzard that pops up select the DALFootballer class and then in the next step choose the GetFootballers method Click Finish to complete the steps of the wizzard Build and Run your application 10 Obviously you will not see any records coming back from your database because we have not inserted anything The database is created though Have a look at the picture below 11 Now let s change the POCO class Let s add a new property to the Footballer cs class public int Age get set Build and run your application again You will receive an error Have a look at the picture below 12 That was to be expected EF Code First Migrations is not activated by default We have to activate them manually and configure them according to your needs We will open the Package Manager Console from the Tools menu within Visual Studio 2012 Then we will activate the EF Code First Migration Features by writing the command Enable Migrations Have a look at the picture below This adds a new folder Migrations in our project A new auto generated class Configuration cs is created Another class is also created CURRENTDATE InitialCreate cs and added to our project The Configuration cs is shown in the picture below The CURRENTDATE InitialCreate cs is shown in the picture below 13 Νοw we are ready to migrate the changes in the database We need to run the Add Migration Age command in Package Manager Console Add Migration will scaffold the next migration based on changes you have made to your model since the last migration was created In the Migrations folder the file 201211201231066 Age cs is created Have a look at the picture below to see the newly generated file and its contents Now we can run the Update Database command in Package Manager Console See the picture above Code First Migrations will compare the migrations in our Migrations folder with the ones that have been applied to the database It will see that the Age migration needs to be applied and run it The EFMigrations CodeFirst FootballeDBContext database is now updated to include the Age column in the Footballers table Build and run your application Everything will work fine now Have a look at the picture below to see the migrations applied to our table 14 We may want it to automatically upgrade the database by applying any pending migrations when the application launches Let s add another property to our Poco class public string TShirtNo get set We want this change to migrate automatically to the database We go to the Configuration cs we enable automatic migrations public Configuration AutomaticMigrationsEnabled true In the Page Load event handling routine we have to register the MigrateDatabaseToLatestVersion database initializer A database initializer simply contains some logic that is used to make sure the database is setup correctly protected void Page Load object sender EventArgs e Database SetInitializer new MigrateDatabaseToLatestVersion FootballerDBContext Configuration Build and run your application It will work fine Have a look at the picture below to see the migrations applied to our table in the database Hope it helps Posted Τρίτη 20 Νοεμβρίου 2012 10 36 πμ από nikolaosk 0 σχόλια Δημοσίευση στην κατηγορία asp net Code First Visual Studio 2012 EF 5 0 Looking into ASP Net MVC 4 0 Mobile Development part 2 In this post I will be continuing my discussion on ASP Net MVC 4 0 mobile development You can have a look at my first post on the subject here Make sure you read it and understand it well before you move one reading the remaining of this post I will not be writing any code in this post I will try to explain a few concepts related to the MVC 4 0 mobile functionality In this post I will

    Original URL path: http://www.dotnetzone.gr/cs/blogs/dotnetrules/archive/2012/11.aspx (2015-07-15)
    Open archived version from archive



  •