Banner Ad

Monday, June 11, 2018

HTML Attributes : readonly VS disabled

By Francis   Posted at   1:44 PM   No comments

                   Recently, i have encountered a problem, that is i need to “disable” some text boxes after it pre filled it’s data from server. As a normal developer i decided to use the “disabled” property of the text box like below:


<input  type="text" id="txtName" disabled />

It works for me. Good! But my requirement expects some more functionalities. That is, whenever the value prefilled in the above text box, after the user clicks the “submit” button which inturn validate the value in client side and fire up the validation messages.


Here is what i stumbled! The problem arised! The “disable” property won’t allow you to edit. It will completely lock the control from edit. After that i come to know about the alternate property called “readonly”, which acts nearly like “disable” property, but one small exception you can fire the client side validations without any problem.


<input  type="text" id="txtName" readonly />


So my learning here is, if you want to lock the control entirely you can go with “disabled” property. If you want to just lock the control and wants to enable the validations means you can go with “readonly”! The above points are opt only for “text boxes” alone!


Below list provides a detailed difference between these 2 properties:


                  disabled                                     readonly                                     
values not passed while submitting the form values will be passed while submit the form
tabbing navigation not possible allow tabbing navigation.
Unable to get focus. Will get focus
Max. HTML controls support “disabled” property like <select>, <option>  and <button>. Not all form elements have readonly attribute suppor.


Hope this helps!

Sunday, July 9, 2017

How to Start My Final Year Project in .Net?

By Francis   Posted at   11:47 AM   ASP.NET Books 1 comment

Most of the college students who are doing their final year projects (especially computer science students) and beginners are asked about the below questions:
  • How to start an ASP.Net Projects?
  • What are the basic Software I need to code .Net?
  • What are the books I referred to become better programmer?
In this post I just want to guide those people by providing some basic tips.

Prerequisite – Skills:
The below are the must have skill sets that are required for every beginner in ASP.Net.
  1. .Net Architecture (CLR and BaseClass Library)
  2. C# or VB.Net Language
  3. ASP.Net (Web Form, Worker Process, AppDomain, Session, Cache, Authentication etc)
                    It is better how the .Net frameworks works which helps to the developer to grasp the rest of the things easily. If you want to go with ASP.Net you should learn any one of the .Net compatible language such that C# or VB.Net. ADO.Net always deals with Database related objects like Datasets, Datatables etc. In beginner level choosing Web Form will give an easy to move, way in ASP.Net. The above lists are specific to .Net.

Prerequisite – Software

Before start your project you need the below softwares:
1. Visual Studio
2. .Net Framework
3. SQL Server
For students and beginners express version of visual studio is enough. While this writing Microsoft released Visual Studio 2013. You can download the Visual Studio 2013 express for web development here. With that installation, .Net framework 4.5 also installed. So there is no separate download is not necessary.
In the meantime, Microsoft also introduced Visual Studio Community Edition, which is a complete set of IDE. So instead of going with Express Edition, you can try it. You can start download it from here.
Each and every website that are developed are data centric or data driven. That are data are stored and retrieved from a database like SQL Server. So you must need that one also. For SQL Server also Microsoft provide express version. You can get it SQL Server 2008 Express with SP2 here and SQL Server 2012 here.
For the above software installation you must need Windows 7 with SP1 or Windows 8.

Some Good Books for ASP.Net:
Below are my personal suggestion to sharpen your skills in ASP.Net as well as .Net Languages such as C# and VB.Net in some extend.

1. Programming ASP.Net By Dino Espotio (From Microsoft Press)
2. Professional ASP.Net 2.0/3.5/4.5 (from wrox publications)
3. C# 4.0 – The Complete Reference By Herbert Schildt

Online Tutorials & Trainings for ASP.Net:
                       For ASP.Net technology, there are so many good online tutorial sites available. Some of them for your reference:

What do you think?
                   The above are my personal experience. Did i miss anything or do you want to say something, please let me know you thoughts as comments.

Wednesday, October 12, 2016

ASP.Net MVC : TempData - A Closer Look

By Francis   Posted at   1:43 PM   TempData and ASP.Net MVC No comments

                As an ASP.Net MVC developer, you may frequently involved with these terms like Tempdata, viewdata and viewbag. In this post, I’m going to take a close look about TempData and how it works.

Read: ViewBag, ViewData and TempData

For explanation purpose, I’m going to create a small MVC project with 3 views and a controller.
  1. Index.cshtml – This is the default view, which is loaded by the default action method.
  2. Page1.cshtml
  3. Page2.cshtml
And the controller named as:
  1. DefaultController.cs 

We will start with TempData. I will set the value of TempData in the Action method “Index”, like below:

using System.Web.Mvc;
namespace SessionHandlingInMVC.Controllers 
    public class 
DefaultController : Controller 
        // GET: Default         
public ActionResult Index() 
          TempData["MyTempDataValue"] = "Value initialized in Index Action Method"; 
          return View(); 
public ActionResult Page1() 
            return View("Page1"); 
public ActionResult Page2() 
      return View("Page2"); 

In the “Index” view, we can get the value of the initialized “Tempdata” value as below:

<h2>Index Page</h2>
       string strTempDataValue = 

Please take a close look how the value is retrieved from the “TempData”.You can’t directly assigned to it the specific type.  A typecasting is needed, when you retrieved the value from Tempdata. The above snippet just get the value from TempData dictionary and print it on.

In the next snippet, I’m going to change the above snippet a little bit like below:

<h2>Index Page</h2> 
strTempDataValue = (string)TempData["MyTempDataValue"]; 
        string strAnotherRead = 

In the above snippet, we have read the TempData value as twice. As a result the value also printed twice in the view.

The above result confirm that, you can read the TempData value inside the current request as much time as possible.

In the following snippet, I’m going to read the value of the TempData in the next view, which is rendered by the action method “Page1”.

strTempDataValueInPage1 = (string)TempData["MyTempDataValue"]; 

In order to test the above scenario, first you must render the view “Index” (since in that action method alone the tempdata value is initialized) and then you call the “Page1” view. As you can see that, TempData value is not available in the next request.

Wait! The conclusion is not yet over. I want to try some thing more. That is, as per the above codes:

1. First I render the “Index” page, where the Tempdata value is read and print it.
2. After I call the action method “Page1”.

What will happens if I didn’t read the value of Tempdata in “Index.cshtml” view and try to read the “Page1.cshtml” view. In order to test, I made the below changes in Index view.

<h2>Index Page</h2> 
    No Temp Data read here 
in Index.cshtml 


strTempDataValueInPage1 = (string)TempData["MyTempDataValue"]; 

Now, you got the value in the value of Tempdata in the next request. That means, your first request render the “Index” page, and the next request render the “Page1”.

If you refresh the above page, you will get the result as below: that is, the Tempdata is unavailable once it read. So you get the Tempdata value as empty.

So the conclusion is : After Tempdata value is initialized and it’s not yet read in the current request, then it will be available in the next request. Once it is read, it will not available.

Few words about Keep() and Peek() method:

After you read the tempdata, if you call the keep method, it will marks the all tempdata keys or specific key for retention.

If you want to fetch the key and mark the key for retention (keep the key for the next request) then you can go with Peek method.

Connection between Session and Tempdata:

Yes, Tempdata uses “Session” object in the backend. That is, whenever you use a tempdata it will handled by session. But the main difference is, the Tempdata will be removed (by default) after the first read.

At the same time, you may have the doubt, that either tempdata is specific to the user as like as “Session”? The answer is Yes. Since the Tempdata, is backed up with Session, Tempdata is also specific to user, like Session object.

Also, the another question is, since the Tempdata backed up with Session, what will happened if we go with same key for session and Tempdata as like below:

The answer is it won’t colloid. It will considered as a different one and it will serve its own purpose as per the convention.

In summary:
  1. TempData store the value using key.
  2. TempData backed up with Session.
  3. Need type casting when the stored value retrieved.
  4. The life time of tempdata is little bit tricky. It will be available till you read it first time. After you read it, it will be marked for deletion. So in the next request, it won’t available.  However, you can extend it’s life time by using keep and peek method.
Readers, did i missed anything? Share your feedback as comments.

Monday, October 10, 2016

ASP.Net : Binding Dropdown in ASP.Net

By Francis   Posted at   7:55 PM   Dropdown Control in Asp.Net No comments
Binding dropdown is a common need in ASP.Net. The below code snippet is used to bind the datatable values to the dropdown list.


<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
            <asp:DropDownList runat="server" ID="ddlCity">

Code behind:

        protected void Page_Load(object sender, EventArgs e)
                //Substitute your DB and Server name below
                string conString = @"Data Source=Your_DBServer_Name;Initial Catalog=Your_DB_Name;Integrated Security=True";
                DataTable dtCity = new DataTable("City");
                // Create Connection and get the DB values
                using (SqlConnection connection= new SqlConnection(conString))
                    SqlCommand command = new SqlCommand(conString,connection);
                    command.CommandText = "Select city_code,city_description from tblCity";
                    SqlDataAdapter adapter = new SqlDataAdapter(command);
                // Set the Datasource
                ddlCity.DataSource = dtCity;
                ddlCity.DataValueField = "city_code";
                ddlCity.DataTextField = "city_description";
                // Finally Bind it

Tuesday, August 2, 2016

ASP.Net MVC - ViewBag, ViewData and Tempdata

By Francis   Posted at   9:08 PM   ASP.Net MVC No comments

                  As an ASP.Net MVC developer, you may frequently involved with these terms like Tempdata, viewdata and viewbag. In this post, I’m going to discuss about what are they and what are the main difference between them.


  1. ViewBag is dynamic in nature.
  2. There is no type casting needed.
  3. Life time lasts only for the current request.

View Data:
  1. ViewData is stored as a dictionary. You can store a value using a key.
  2. Type casting is needed, when you retrieve.
  3. Life time lasts only for the current request.


  1. It’s also store the value using key.
  2. Need type casting when the stored value retrieved.
  3. The life time of tempdata is little bit tricky. It will be available till you read it first time. After you read it, it will be marked for deletion. So in the next request, it won’t available.  However, you can extend it’s life time by using keep and peek method.

Hope this helps!
Connect with Us