If you are developing an application, you should prepare for exceptions in your application. Exceptions are part of the applications. An exception means an error and it is run time error. In this blog I will explain how to avoid these unwanted exceptions in your applications. Exceptions – As I already told you that exception is not a compile time error. Exception is a run time error. We ...
There are different types of classes in C sharp like Sealed, Abstract, Partial, etc. In this blog I will explain abstract class in C sharp. Abstract class is very useful in C sharp. Below you will learn about Abstract class, Abstract methods and Abstract properties. There is main difference in Abstract class that Abstract class can’t be instantiated. An Abstract class is only a base clas...
Today someone asked on forums that how to open a alert box from user control.So I am writing a blog on it. There is a user control and an aspx.page. In user control, I have one button and in user control's code behind file alert box code. User Control Code - <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="testQuestionUC.ascx.cs" Inherits="WebProjects.UserControl.testQuest...
Beginners are always confused about AutoEventWireup attribute of a Page directive. In this blog, I will explain AutoEventWireup and try to help out beginners. I hope programmers wouldn’t confuse about AutoEventWireup attribute after read this blog. When I create a new aspx page, Page directives have four attributes – Language, AutoEventWireup, CodeFile, and Inherits. AutoEventWireup – Au...
Today I have read a question on forums asp.net. So I thought I should write a blog on this. Question - How do I get Date, month, year in three different dropdownlist? Well below you will see you how we can show Date, Month and Year in three different dropdownlist. Code - <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title>...
Every Beginner have confused about IsPostBack property. Below you will find a very simple example of IsPostBack property. IsPostBack property returns Boolean value. It is used to determine if data is being sent back to the Web server or if the Web page is simply being requested. Example :- <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled...
When programmers use and manipulations with a null object, they always faced an error. The error is ‘ Object reference not set to an instance of an object .’ In below example I will show you that how this error comes and how we can solve this problem. Error - Let’s say you are getting value from the database. When you are getting value from the database, you would get an about error. Now...
I have seen many times a question on Internet which is “Input String was not in a correct format”. I have also faced this error. This is run time error. Types of Error – Compile time error (Syntax error, etc.) Runtime error (Division by zero, etc.) As I told you that “Input string was not in a correct format” is a runtime error. Mostly it comes when we convert a string to a number or con...
In this blog I will explain how I can use Textbox, Radio button list, Checkbox and Dropdown list selector in jQuery. What is selector? Selector is backbone of jQuery language. Selector means you can select an element or group of Elements to perform any action. Example:- <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script sr...
In this blog I will explain Literal control in ASP.NET. The Literal control used to display static text on a web page. Literal control is not rendered as a <span> tag like label control. The Literal control doesn’t inherit from WebControl and we can’t apply style to its content because it doesn’t have a style property. There is a Mode property of Literal control. There are three mo...
Yesterday, I was sitting with my college friends at a coffee shop. One of my friends asked me a question that how we can find highest second and lowest second number in a particular array, and without the help of any function like orderBy. So, I took a notebook and solved his question. Now I am writing a blog on that logic as I want to share my logic with everybody. Here is my code:- usi...
Today one of my colleague asked me a simple question that how I can generate set of 10 unique random numbers. First I thought it is very simple but later I found it’s very logical. So I thought I should write a blog on this. Here is my code - using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public p...
Web Service – Web Service is a huge thing in ASP.NET. Using web Service, We can create robust web applications. We can create Web service’s methods and that function can be accessible to the rest of the world. ASP.NET provides easy way to develop Web services. With the help of Web services we can share data across different platforms. In this blog I will explain only how to insert data i...
In this blog I will explain how to find control in nested Data list. I will also tell you how you can bind nested Data list. In below code there is a class file (DummyData.cs) and a page (NestedDatalist.aspx). Here is my code:- NestedDatalist.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeFile="NestedDatalist.aspx.cs" Inherits="NestedDatalist" %> <!DOCTYPE html PUBLIC "-...
In this blog I will explain how to upload some particular file upload in ASP.NET. In below code there is a fileupload (fuTest) and a button (btnUpload) control. <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <table> <tr> <td><asp:Fi...
In this blog I will tell how many Data types in C#. There are following Data types built into C# and each one stores a different kind of data. Note: whole number – its means it doesn’t have a decimal point. Data Type Description Bits int int can store any whole Number from -2,147,483,648 to 2,147,483,647 32 bits string String can hold text of any length bool bool is a Boolean value it’s ...
In this blog I will explain how to prevent duplicate value in a table. I have a Student form. In this form user can insert student’s details. But duplicate value in Roll No field isn’t allowed. In below example I show you how you can stop duplicate value in a field. Here is my code:- In this StoredProcedure I am checking Roll no, if it is already exist then it won’t save in database. CRE...
In this blog I will explain how to write a text file in ASP.NET. Here is my code:- There is a Textbox and one button. You can type your name in textbox and it will write into your text file. You can check your text file in D drive (D:\). ASPX Code:- <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <for...
Last week I have checked a website. In that website I saw my name and when I clicked on my name, it changed into a textbox and asks me update for my name. I found it very good. Today I have created a new dummy project on this functionality. Here is my Code:- <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <script typ...
Today I was working on checkbox. I have faced a problem and problem was how I can insert value in Textbox on Checkbox‘s checked event (without postback) . But at last I have solved this problem.I thought I should write a blog that how we can insert value in textbox on Checkbox’s checked event. Here is my dummy project:- In below code there are three checkboxes and one textbox. When user ...
In this blog I will explain how to open a JavaScript alert from Code-behind file. I want to show ‘Welcome’ alert on page load. Below is my code:- protected void Page_Load(object sender, EventArgs e) { Response.Write("<script>alert('Welcome')</script>"); } Happy Coding:)
In this blog I will explain how to create DataTable. here is my code:- creating Table first- private DataTable myTestTable() { DataTable myTable = new DataTable(); DataColumn myColumn; myColumn = new DataColumn(); myColumn.DataType = Type.GetType("System.String"); myColumn.ColumnName = "Name"; myTable.Columns.Add(myColumn); myColumn = new DataColumn(); myColumn.DataType = Type.GetType("S...
In this blog I will explain Unique constraint in SQL.If i create a UNIQUE constraint, i can't insert duplicate data in that column. The UNIQUE constraint ensures that all values in a column are distinct. Example i have created a Table:- CREATE TABLE UNIQUE_EXAMPLE ( ID INT UNIQUE, Name VARCHAR(50) ) Now I am inserting data in UNIQUE_TABLE:- INSERT INTO UNIQUE_EXAMPLE values ('1','Mohit')...
In this blog I will explain how to use two-dimensional array in C#. Here is my aspx code:- <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="txt2dArray" runat="server" TextMode="MultiLine"></asp:TextBox> </div> </form> </body> Here is my Code behind code:- namespace Test { public partial class _Default : System.Web.UI.Page { pr...
In this Blog I will explain how we can gernerate random number. Example - <HTML> <HEAD> <SCRIPT type="text/javascript"> function GenerateRandomNo() { var _date=new Date() var ran_num=(_date.getSeconds())%10 var ran_num=ran_num+1 alert(ran_num) } </SCRIPT> </HEAD> <BODY> <form> <INPUT TYPE="button" VALUE="Generate Number from 1 to 10" onClick="...
It's fast, easy and free! Submit articles, get your own blog, ask questions & give answers in the forums, and become a better developer, faster.
enter your email address:
What kind of email newsletter would you prefer to receive from CodeAsp.Net?18