This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Me And My Respected Teacher Mr Kamal Sheel Mishra

Mr. K.S. Mishra is HOD of Computer Science from SMS Varanasi where I have completed my MCA

Me And My Respected Teacher Mr Udayan Maiti

Mr. Udayan Maiti is a senior .Net Expert and has guided many professionals of multi national Companies(MNC)

Me And My Best Friend Mr Ravinder Goel

Mr. Ravinder Goel is a senior Software Engineer and now he is working Wipro Technology

Monday, 16 June 2014

AutoCompeleteExtender TextBox in Mvc 4.0 with Jquery Json

 AutoCompeleteExtender TextBox in Mvc 4.0 with Jquery Json

 use MvcwithJquery

--create table State……………………………………
create  table State
(
StateId int primary key,
StateName varchar(50) unique
)

--insert data in table  state………………………………..

insert into State values(1,'Assam')
insert into State values(2,'Arunachal Pradesh')
insert into State values(3,'Andhra Pradesh')

select *  from State order by stateid

First  we take MvcApplication which name is MvcAutoCompleteExtender   and add Controller in your MVCApplication which name is Home……………….

This code applies for Controller page which name is Home.cs……………….

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
// add this namespace............
using MvcAutoCompleteExtender.Models;

namespace MvcAutoCompleteExtender.Controllers
 {
 public class HomeController : Controller
{
//
// GET: /Home/

public ActionResult Index()
{
return View();
}
MvcwithJqueryEntities1 mm = new MvcwithJqueryEntities1();

//  code for how to get statename from Sql Server using Json…….

public JsonResult GetStateName(string StateName)
{

var v = (from m in mm.States where m.StateName.StartsWith(StateName) select m).ToList();
if (v != null)
{
return Json(v, JsonRequestBehavior.AllowGet);
}
else
return Json("Failed");
}
}
}

This code applies for View page which name is Index.cshtml……………….

@{
ViewBag.Title = "Index";
}
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>

<script src="~/Scripts/jquery-1.7.1.min.js"></script>

<script type="text/javascript">
$(function ()
{
$('#txtstatename').keyup(function () {

$('#2').html('');
var statename = $(this).val();

if (statename != '')
{
$.getJSON('../Home/GetStateName', { StateName: statename }, function (data) {
if (data != null)
{
var div = '';
var no=0;
div+= '<div id="3" style="border:1px solid black; width:150px; height:0px">';
$.each(data, function (i, item) {
no = no + 1;
div += '<a style="text-decoration:none; color:black" href="#" id=' + i + '>' + item.StateName + '</a></br>';
});
var height = no * 20;
div += '</div>';
$('#displaystate').append(div);
$('#3').animate({ height: height });


$('a').click(function (event) {
event.preventDefault();
var id = $(this).attr('id');
var h = $(this).html();
$('#txtstatename').val(h);

}); 
}
}); 
}    
});  
});

</script>
</head>

<body>
<table>
<tr><td><center><b><i>AutoCompeleteExtender in Mvc 4.0 with Jquery Json</i></b></center></td></tr>
<tr><td>State Name</td><td>
<div id="main">
<input type="text" id="txtstatename" placeholder="State Name"  />
</div>
<div id="displaystate" style="height:0px">
</div>
</td></tr>
<tr><td></td><td></td></tr>
</table>
</body>
</html>

Result:



Tuesday, 10 June 2014

Call by Value Call by Reference and Params Concept in C# .Net

Call by Value Call by Reference and Params Concept  in C# .Net...................

Call by value: In the call by value method, the called function creates a new set of variables in stack and copies the values of the arguments into them.

Example: Program showing the Call by Value method..........................

First we will create class which name is Class1 and defined method Swap with two no...

class Class1
{
public void Swap(int a, int b)
{
a = a + b;
b = a - b;
a = a - b;
MessageBox.Show("Swapped values are a = " + a + "and b = " + b);
}
}

Then we will take a Window From with two TextBox ………………………………

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CallByValueandReference
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int a, b;
Class1 cc = new Class1();
private void btnswap_Click(object sender, EventArgs e)
{
a = Convert.ToInt32(textBox1.Text);
b = Convert.ToInt32(textBox2.Text);
MessageBox.Show("Original values are a = "+ a +"and b="+ b);
cc.Swap( a,  b);
MessageBox.Show("The values after swap are a = " + a + "and b =" + b);
}
}
}
Output:

Call by reference: In the call by reference method, instead of passing values to the function being called, references/pointers to the original variables are passed.

Example: Program showing the Call by Reference method.........................

First we will create class which name is Class1 and defined method Swap with two no.........

class Class1
{
public void Swap(ref int a , ref  int  b)
{
a = a + b;
b = a - b;
a = a - b;
MessageBox.Show("Swapped values are a = " + a + "and b = " + b);
}

Then we will take a Window From with two TextBox ………………………………

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CallByValueandReference
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

int a, b;
Class1 cc = new Class1();
private void btnswap_Click(object sender, EventArgs e)
{
a = Convert.ToInt32(textBox1.Text);
b = Convert.ToInt32(textBox2.Text);
MessageBox.Show("Original values are a = "+ a +"and b="+ b);
cc.Swap(ref  a ,ref  b);
MessageBox.Show("The values after swap are a = " + a + "and b =" + b);
}
}
}
Output:



What is Params : its enables methods to receive variable numbers of parameters. With params, the arguments passed to a method are changed by the compiler to elements in a temporary array. In other way we can say you are not assured about number of parameters or you want to create a method that can accept n number of parameters at run time. This situation can be handled with params type array in C#. The params keyword creates an array at run time that receives and holds n number of parameters.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CallByValueandReference
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

class Class1
{
// params concept in C# .net
public int sum(params int[] arr)
{
int total = 0;
foreach (int a in arr)
total += a;
return total;
}
}

private void button1_Click(object sender, EventArgs e)
{
Class1 cc = new Class1();
int res = cc.sum(2, 8, 9, 08, 34, 23);
MessageBox.Show(res.ToString());
}
}
}
Output: