Model: The business entity on which the overall application operates. Many applications use a persistent storage mechanism (such as a database) to store data. MVC does not specifically mention the data access layer because it is understood to be encapsulated by the Model.
View: The user interface that renders the model into a form of interaction.
Controller: Handles a request from a view and updates the model that results a change in Model’s state.
To implement MVC in .NET we need mainly three classes (View, Controller and the Model).
The buzz around responsive design has been going on for several months now, and a lot of websites are already responsive, or underway. You know what that means? Today I will teach you how to create a responsive website.
If you follow 1WD on Facebook or Twitter, then you already know that we’re already preparing for an explosive design, which includes being responsive. Watch out for it!
Tutorial Level: Beginner
Skills Required: Basic knowledge in HTML and CSS
Completion Time: Approximately 15 minutes
Warning: this tutorial is targeted towards beginners, but it can also be for designers and developers who want to have fun!
By the end of this quick tutorial about responsive design, you will already be on your way to web stardom, and by that I mean you’ll be ready to convert and create responsive websites!
Are you ready? Show me your war faces! Roaaar!
Preparing for the Responsive Website Tutorial
I promised that it will only take about 15 minutes to create a responsive website, and I will hold true to my words. Only, we shall start slow and small. We will start by creating a simple single-page website. Cool? Okay!
HTML5 is here, and the Web will never be the same.
You’ve no doubt heard that before, or something like it. I’d guess that when you did, you got excited, rolled your eyes, or mouthed the word “why?” and furrowed your brow a bit. Perhaps your reaction was a mix of all three.
I wouldn’t blame you for any of these. HTML5 is exciting, and it does have the potential to change the Web as we know it, but it also gets blown out of proportion. What’s more, its true meaning can be elusive. I’ve experienced each of those reactions myself while building applications with HTML5. It’s a broad topic, so it’s difficult to wrap your head around HTML5, much less know where to begin with this exciting new set of technologies.
This is the first article in a series for MSDN Magazine, and the goal is to give you a complete picture of why the first sentence in this article is true—and important. Over the next several months, I want to help you understand what HTML5 means to you—both as a Web developer and as a developer who uses Microsoft tools and technologies. I hope to simplify some of the complexity around HTML5 for you, and demystify much of the hype. I’ll also introduce some HTML5 features that are available today, as well as some exciting technologies that, though a bit further out, are worth paying attention to. Finally, I’ll leave you with some tips that will help you adopt HTML5 technologies now, while you continue to provide great experiences to users with older browsers.
If you’re excited about HTML5, I want to help you turn that excitement into ideas you can put into practice immediately. If you’re skeptical, I want to help you understand just why HTML5 is important. And if you’re just confused about what HTML5 even means, fear not: that’s our first stop in this series.
Exporting GridView Data to Excel Sheet in ASP.NET is a common task for many Applications. In this article I am explaining problem and solution for this task.
In this article, I am going to explain steps for exporting GridView Data to Excel Sheet and what are the problems we face in this task.
There are two cases when you export GridView Data-
1. GridView without control like (Button, LinkButton, ImageButton etc.)
2. GridView with control like (Button, LinkButton, ImageButton etc.)
How long does it take to create a new website? Is it a matter of days or weeks? Wrong: it’s a matter of hours! If you have doubts, then you have never used website templates (web designs that enable you to build static websites)or Flash templates(web designs that enable you to build animated websites). So, why don’t you download afree website templateor afree Flash templateand test it? After all, free templates are free and you have nothing to loose.
With the great popularity of tablets and smart-phones, the demand for responsive website design is more serious than ever. Right now, more and more websites are adopting responsive layouts and this trend is expected to become more intense as the percentage of mobile Internet users increase. This development have created tremendous demand for the services of web designers and developers proficient in this highly adaptable system of website layouts. Already, we can see responsive WordPress themes, available from major theme providers that meet the challenges of adopting to different screen sizes.
As expected, some pretty useful responsive web design tools have surfaced recently to support the design and development process of responsive websites. Thanks to the large community of talented developers who made all these resources available. You may ask – what exactly is a responsive web design tool used for? Which tools do I need myself to be ahead of the responsive game? If you are a web designer or developer considering to explore and possibly specialize in responsive web design, you have come to the right place. We are sharing with you, some of the most useful tools and resources here to help you build a responsive design toolbox.
Security of ASP.net Web is a huge concern. Therefore, i am going to share with you some Very good articles and tutorials.If you want to make strong your website/web Application User Authentication and Login or you want to learn it from scratch then please visit this link and study there.
This tutorial shows how to use SignalR to create a real-time chat application. You will add SignalR to an empty ASP.NET web application and create an HTML page to send and display messages.
Overview
This tutorial introduces SignalR development by showing how to build a simple browser-based chat application. You will add the SignalR library to an empty ASP.NET web application, create a hub class for sending messages to clients, and create an HTML page that lets users send and receive chat messages. For a similar tutorial that shows how to create a chat application in MVC 4 using an MVC view, see Getting Started with SignalR and MVC 4.
SignalR is an open-source .NET library for building web applications that require live user interaction or real-time data updates. Examples include social applications, multiuser games, business collaboration, and news, weather, or financial update applications. These are often called real-time applications.
SignalR simplifies the process of building real-time applications. It includes an ASP.NET server library and a JavaScript client library to make it easier to manage client-server connections and push content updates to clients. You can add the SignalR library to an existing ASP.NET application to gain real-time functionality.
The tutorial demonstrates the following SignalR development tasks:
Adding the SignalR library to an ASP.NET web application.
Creating a hub class to push content to clients.
Using the SignalR jQuery library in a web page to send messages and display updates from the hub.
The following screen shot shows the chat application running in a browser. Each new user can post comments and see comments added after the user joins the chat.
This section shows how to create an empty ASP.NET web application, add SignalR, and create the chat application.
Prerequisites:
Visual Studio 2010 SP1 or 2012. If you do not have Visual Studio, see ASP.NET Downloads to get the free Visual Studio 2012 Express Development Tool.
Microsoft ASP.NET and Web Tools 2012.2. For Visual Studio 2012, this installer adds new ASP.NET features including SignalR templates to Visual Studio. For Visual Studio 2010 SP1, an installer is not available but you can complete the tutorial by installing the SignalR NuGet package as described in the setup steps.
The following steps use Visual Studio 2012 to create an ASP.NET Empty Web Application and add the SignalR library:
In Visual Studio create an ASP.NET Empty Web Application.
In Solution Explorer, right-click the project, select Add | New Item, and select the SignalR Hub Class item. Name the class ChatHub.cs and add it to the project. This step creates the ChatHub class and adds to the project a set of script files and assembly references that support SignalR.
Note: You can also add SignalR to a project by opening the Tools | Library Package Manager | Package Manager Console and running a command: install-packageMicrosoft.AspNet.SignalR. If you use the console to add SignalR, create the SignalR hub class as a separate step after you add SignalR.
In Solution Explorer expand the Scripts node. Script libraries for jQuery and SignalR are visible in the project.
Replace the code in the new ChatHub class with the following code.
usingSystem;usingSystem.Web;usingMicrosoft.AspNet.SignalR;namespaceSignalRChat{publicclassChatHub:Hub{publicvoidSend(string name,string message){// Call the broadcastMessage method to update clients.Clients.All.broadcastMessage(name, message);}}}
In Solution Explorer, right-click the project, then click Add | New Item. In the Add New Item dialog, selectGlobal Application Class and click Add.
Add the following using statements after the provided using statements in the Global.asax.cs class.
Add the following line of code in the Application_Start method of the Global class to register the default route for SignalR hubs.
// Register the default hubs route: ~/signalr/hubsRouteTable.Routes.MapHubs();
In Solution Explorer, right-click the project, then click Add | New Item. In the Add New Item dialog, select Html Page and click Add.
In Solution Explorer, right-click the HTML page you just created and click Set as Start Page.
Replace the default code in the HTML page with the following code.
<!DOCTYPE html><html><head><title>SignalR Simple Chat</title><styletype="text/css">.container {background-color:#99CCFF;border: thick solid #808080;padding:20px;margin:20px;}</style></head><body><divclass="container"><inputtype="text"id="message"/><inputtype="button"id="sendmessage"value="Send"/><inputtype="hidden"id="displayname"/><ulid="discussion"></ul></div><!--Script references. --><!--Reference the jQuery library. --><scriptsrc="/Scripts/jquery-1.8.2.min.js"></script><!--Reference the SignalR library. --><scriptsrc="/Scripts/jquery.signalR-1.0.0.js"></script><!--Reference the autogenerated SignalR hub script. --><scriptsrc="/signalr/hubs"></script><!--Add script to update the page and send messages.--><scripttype="text/javascript">
$(function(){// Declare a proxy to reference the hub. var chat = $.connection.chatHub;// Create a function that the hub can call to broadcast messages.
chat.client.broadcastMessage =function(name, message){// Html encode display name and message. var encodedName = $('<div />').text(name).html();var encodedMsg = $('<div />').text(message).html();// Add the message to the page.
$('#discussion').append('<li><strong>'+ encodedName
+'</strong>: '+ encodedMsg +'</li>');};// Get the user name and store it to prepend to messages.
$('#displayname').val(prompt('Enter your name:',''));// Set initial focus to message input box.
$('#message').focus();// Start the connection.
$.connection.hub.start().done(function(){
$('#sendmessage').click(function(){// Call the Send method on the hub.
chat.server.send($('#displayname').val(), $('#message').val());// Clear text box and reset focus for next comment.
$('#message').val('').focus();});});});</script></body></html>
Save All for the project.
Run the Sample
Press F5 to run the project in debug mode. The HTML page loads in a browser instance and prompts for a user name.
Enter a user name.
Copy the URL from the address line of the browser and use it to open two more browser instances. In each browser instance, enter a unique user name.
In each browser instance, add a comment and click Send. The comments should display in all browser instances.
Note: This simple chat application does not maintain the discussion context on the server. The hub broadcasts comments to all current users. Users who join the chat later will see messages added from the time they join.
The following screen shot shows the chat application running in three browser instances, all of which are updated when one instance sends a message:
In Solution Explorer, inspect the Script Documents node for the running application. There is a script file named hubs that the SignalR library dynamically generates at runtime. This file manages the communication between jQuery script and server-side code.
Examine the Code
The SignalR chat application demonstrates two basic SignalR development tasks: creating a hub as the main coordination object on the server, and using the SignalR jQuery library to send and receive messages.
SignalR Hubs
In the code sample the ChatHub class derives from the Microsoft.AspNet.SignalR.Hub class. Deriving from theHub class is a useful way to build a SignalR application. You can create public methods on your hub class and then access those methods by calling them from jQuery scripts in a web page.
In the chat code, clients call the ChatHub.Send method to send a new message. The hub in turn sends the message to all clients by calling Clients.All.broadcastMessage.
The Send method demonstrates several hub concepts :
Declare public methods on a hub so that clients can call them.
Use the Microsoft.AspNet.SignalR.Hub.Clients dynamic property to access all clients connected to this hub.
Call a jQuery function on the client (such as the broadcastMessage function) to update clients.
publicclassChatHub:Hub{publicvoidSend(string name,string message){// Call the broadcastMessage method to update clients.Clients.All.broadcastMessage(name, message);}}
SignalR and jQuery
The HTML page in the code sample shows how to use the SignalR jQuery library to communicate with a SignalR hub. The essential tasks in the code are declaring a proxy to reference the hub, declaring a function that the server can call to push content to clients, and starting a connection to send messages to the hub.
The following code declares a proxy for a hub.
var chat = $.connection.chatHub;
Note: In jQuery the reference to the server class and its members is in camel case. The code sample references the C# ChatHub class in jQuery as chatHub.
The following code is how you create a callback function in the script. The hub class on the server calls this function to push content updates to each client. The two lines that HTML encode the content before displaying it are optional and show a simple way to prevent script injection.
chat.client.broadcastMessage =function(name, message){// Html encode display name and message. var encodedName = $('<div />').text(name).html();var encodedMsg = $('<div />').text(message).html();// Add the message to the page.
$('#discussion').append('<li><strong>'+ encodedName
+'</strong>: '+ encodedMsg +'</li>');};
The following code shows how to open a connection with the hub. The code starts the connection and then passes it a function to handle the click event on the Send button in the HTML page.
Note: This approach insures that the connection is established before the event handler executes.
$.connection.hub.start().done(function(){
$('#sendmessage').click(function(){// Call the Send method on the hub.
chat.server.send($('#displayname').val(), $('#message').val());// Clear text box and reset focus for next comment.
$('#message').val('').focus();});});
Next Steps
You learned that SignalR is a framework for building real-time web applications. You also learned several SignalR development tasks: how to add SignalR to an ASP.NET application, how to create a hub class, and how to send and receive messages from the hub.
You can make the sample application in this tutorial or other SignalR applications available over the Internet by deploying them to a hosting provider. Microsoft offers free web hosting for up to 10 web sites in a free Windows Azure trial account. For a walkthrough on how to deploy the sample SignalR application, see Publish the SignalR Getting Started Sample as a Windows Azure Web Site. For detailed information about how to deploy a Visual Studio web project to a Windows Azure Web Site, see Deploying an ASP.NET Application to a Windows Azure Web Site. (Note: The WebSocket transport is not currently supported for Windows Azure Web Sites. When WebSocket transport is not available, SignalR uses the other available transports as described in the Transports section of theIntroduction to SignalR topic.)
To learn more advanced SignalR developments concepts, visit the following sites for SignalR source code and resources: