Posts

Showing posts with the label C#

Simply Notes #2: Single Click File Upload in ASP.Net

For those who hate to click more than required and like Scott Hanselman said 

"There are a finite number of keystrokes left in your hands before you die.

I definitely have very little left to spare and I am still writing this! - Check yours

Here is one way of doing file upload in single click


Keep fileupload control hidden using css stylesOn client click of the upload link button trigger the fileupload click event and return false so that server side click event is not firedNow bind an onchange event for the fileupload controlOnchange event trigger the server side click event of upload link buttonOn upload link server click save the file on server






Chat application using SignalR

Image
I know what is magic about now, its just that it somehow works and we don't know how.
So was this chat app a magic for me, until yesterday when i got to know how it works.

In this post we will try to create a chat application that works with approximately 10-12 lines of real code. ( i am sure we can write that in one line too ;) )

The chat recipe goes like this

Ingredient:
SingnalR is solution for ASP.NET which lets communicate with client and the server-side with JS and ASP.NET.
MVC3

Procedure:

Create an empty MVC application ( Which is not really empty)Create a HomeController by right clicking on the controller folderInstall latest Jquery and SignalR using NugetNow create a model Communicator which inherits the Hub from SignalR just like this

on the html side do this

There's your tasty treat :) 
Server-side: uses the dynamic object to call the function defined on the client side.
Client-side: client creates an object of the communicator object and call the function on server-sid…