Showing posts with the label ASP.NET

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

KISS Tabular View

KISS- Keep it Simple Stupid

This post is about a simple html tabular view using bootstrap and a kind of raw grid with sort & search option using ASP.MVC framework.

I always like to keep a lot of things (not everything) simple, not that i don't like owning NOT so simple things ;) 
From development perspective the KISS principle has been spreading lately. Simplicity, the first thing that pops up when i hear that word, it would be Google. Well in fact "simple" is more like "beauty" it's in the eye of the beholder. Here is a sample whose idea on simple contradict with that of mine. May be we can't jump into conclusion that if something is simple to someone it is the same for the other.
So on that same idea of Simple i will try to make a simple page with a simple grid with simple lines of code.

Here is simple table which has got nothing to do with this post.

Let us Create trivial class Employee like this

Now lets create a PersonController and return a dummy lis…

Chat application using SignalR

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

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


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…

WCF web service & Jquery

Here is a new item we can try out, seems to be very light. In this post i will walk through a simple credential validation. Create a simple ASP.NET projectAdd a the following mark-up in your Login.aspx page     <div>         <input type="text" id="username" />         <input type="password" id="password" />         <input type="button" id="login" value="Login" />     </div> Add jquery library and reference     <script src="Scripts/jquery-1.5.1.js" type="text/javascript"></script> Add WCF ServiceSet aspNetCompatibilityEnabled attribute to true in your web.config file     <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" /> Set Factory attribute to "System.ServiceModel.Activation.WebScriptServiceHostFactory" in the service.svc markup and also add the reference to System.ServiceMod…

Datalist Image

Was once wondering how to get images from the database and display it in a datalist control or a datagrid control in ASP.NET, and came across the following probable solution (alternate ideas on this would be appreciated ).


1.Get the image from the database and store it temporarily on the server side.
2.Set the ImageUrl property of the Image control to the temporary path.

Coding goes something like this,

aspx Page:

Datalist control included a image control and a label control to hold description.

<asp:DataList ID="DataList1" runat="server" >
            <asp:Image ID="Image1" runat="server" Width="50" Height="50"/>
            <asp:Label ID="Label1" runat="server" ></asp:Label>

now when binding the grid to the database,

it would have been straightforward if at all path of the image was stored in the data…