Related Posts Plugin for WordPress, Blogger...

About

Follow Us

Tuesday, 30 June 2015

In this article I will explain how to write data to xml file and read from it in asp.Net using c#.

Steps to follow to write and read data from XML file:

1.      First of all create a website and then create on xml File ex. XMLFile.xml.
2.      Then create one webpage and design this webpage to insert data into xml file and show data in Datalist control as given below:

Monday, 29 June 2015


Introduction:
In this article I will explain how to enlarge images  on mouse over. Suppose we want to create a photo gallery which contains thumbnails of images (from database) and we want to show large image on mouse over. This could be possible by using jQuery.

In this example I will show images from database and will display thumbnails on the webpage in Datalist control. When we take the mouse over any thumbnail image then the large version of that image will appear in the specified Div. It will work like a slider in my example.

Friday, 26 June 2015

JavaScript array is an object that represents a collection of similar type of elements. We can create array in javascript. There are 3 ways to construct array in JavaScript
1.    By array literal
2.    By creating instance of Array directly (using new keyword)
3.    By using an Array constructor (using new keyword)

1.      JavaScript array literal

Syntax:


var arrayname=[value1,value2.....valueN];  

Values are contained inside [ ] and separated by , (comma).
Example of creating and using Array:

The .length property returns the length of an array.
<script> 
            var Student=["Vishal","Ankit","Anish"]; 
            for (i=0;i< Student.length;i++){ 
document.write(Student[i] + "<br/>"); 
            } 
</script>

Output :
Vishal
Ankit
Anish

2.     JavaScript Array directly (new keyword)

Syntax:  

var arrayname=new Array();  

Here, new keyword is used to create instance of array.
Example:
  <script>
      var i;
      var emp = new Array();
      emp[0] = "Anish";
      emp[1] = "Ajay";
      emp[2] = "Anuj";

      for (i = 0; i < emp.length; i++) {
          document.write(emp[i] + "<br>");
      } 
</script> 

Output :

Anish
Ajay
Anuj

3.     JavaScript array constructor (new keyword)
In this method, we need to create instance of array by passing arguments in constructor so that we don't have to provide value explicitely.

Example:

<script>
    var emp = new Array("Anuj", "Akhil", "Abhay");
    for (i = 0; i < emp.length; i++) {
        document.write(emp[i] + "<br>");
    } 
</script> 

Output :

Anuj
Akhil
Abhay

Thursday, 25 June 2015

Exceptional Handling In SQL Server:

Error or exception handling in sql server is easy task. In Sql server we can find the error using TRY CATCH statement, which helps us to find the error effectively in the back end. Exceptional handling provides additional information about the errors such as Error Message, Error Line, Error Number etc.
We put Sql statement in TRY block and to handle error we write code in CATCH block. If error occurs in try block then control automatically goes to CATCH block.

Wednesday, 24 June 2015

String in Javascript:

The javascript string is an object which represents sequence of character.

We can create string in javascript in two ways:

1.      Using String Literal
2.      Using String object

1.      Using String literal: syntax to create string using string literal:
Var newstr= “This is string”;

Example:
<script>
        var newstr = "this is new string";
        document.write(newstr);
    </script>

2.     Using String Object:

Syntax to create new string using string object as given below:

Var newstr= new String(“new string”);

Example:
    <script>
        var newstr = new String("this is new string");
        document.write(newstr);

    </script>

Tuesday, 23 June 2015

Objects in javascript:

Object in javascripts is an entity having properties and methods. For example: car pen etc.
Javascript is object oriented language.  Javascript is not class based language it is template based. So without class we can create object in javascript directly.

How to create objects in javascript:

There are three methods to create objects:

1.      By object literal
2.      By creating instance of Object directly (using new keyword)
3.      By using an object constructor (using new keyword)

1.  Javascript object by Object Literal:


Syntax of creating object using object literal:

Obj_name={property1:value1, property2:value2,property3:value3,…..}

Example:

<script>
        student = { name: "ankit", age: 22, class: 10 }
        document.write(student.name+" "+student.age+" "+ student.class)

</script>


2.  By creating Instance of object:

Syntax of creating object directly:

var obj_name= new Object();  


We use new keyword to create object.

Example:
<script>
        var student = new object();
         student.name= "ankit";
          student.age= 22;
          student.class= 10;
        document.write(student.name+" "+student.age+" "+ student.class)
    </script>

3.  Using Object Constructor:

We create a function with arguments. Each argument value can be assigned in current object by using “this operator”.

“this operator” refers to current object.

Example:

<script>
        function students(name, age, classs){
         this.name=name;
         this.age=age;
          this.class=classs;
          }
          student=new students("Ankit", 22,10)
        document.write(student.name+" "+student.age+" "+ student.class)

    </script>

Tuesday, 9 June 2015

Introduction: 
In this article I will explain how to fill or filter a gridview based on dropdown selected value in asp.net using c#, vb.net. In his article I will filter the gridview data according to dropdown selection. First of all I will bind the dropdown with data from database and then gridview. After binding the data from database I will filter the data based on dropdown selection.

Monday, 8 June 2015

Introduction: 

In this article I will explain how to fill a jQuery autocomplete textbox from database 
in asp.net using c#, vb.net with example
 and show / display no results found message in autocomplete textbox when no matching records found in asp.net using c#, vb.net.

Friday, 5 June 2015

Introduction

In this article I will explain how to use jQuery to set dropdownlist selected value or text based on value / text with the help of jQuery.
Introduction

In this article I will explain how to set dropdownlist selected value on page load or code behind in asp.net (c#, vb.net). In dropdownlist we can set selected item by value or text using FindByValue and FindByText properties.
We have two different methods to set dropdownlist selected value.

Method 1: Set Dropdownlist Selected Value Based on value
using FindByValue property we can set dropdownlist selected value

ddlusers.Items.FindByValue("4").Selected = true;

Method 2: Set Dropdownlist Selected value based on Text
using FindByText property we can set dropdownlist selected value

ddlusers.Items.FindByText("Sales").Selected = true;

Source Code for sample Application:
Design your page as given below:

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>set dropdownlist default value in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
 <fieldset style="width:250px">
    <legend><strong>Set Default Value OF dropdown </strong></legend>
<div>
<asp:DropDownList ID="ddlDept" runat="server">
<asp:ListItem Value="1">HR</asp:ListItem>
<asp:ListItem Value="2">Marketing</asp:ListItem>
<asp:ListItem Value="3">Production</asp:ListItem>
<asp:ListItem Value="4">Sales</asp:ListItem>
<asp:ListItem Value="5">Inventory</asp:ListItem>
</asp:DropDownList>
</div></fieldset>
</form>
</body>
</html>


ASP.Net code Behind file code:

C# Code
write the code like as shown below
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// set dropdownlist selected based on text
ddlusers.Items.FindByText("Sales").Selected = true;
}
}

VB.NET Code

Partial Class VBCode
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
' set dropdownlist selected based on text
ddlusers.Items.FindByText("Sales").Selected = True
End If
End Sub

End Class