Good Morning!!!
I think we are good in transforming our data while displaying in browser web pages , sometimes it becomes complex but can be easily done by using angular js filters.
- String
- Number.
- Date
- Object
u can access complete doc here
Welcome to the Codes decoder Home
Good Morning!!!
I think we are good in transforming our data while displaying in browser web pages , sometimes it becomes complex but can be easily done by using angular js filters.
u can access complete doc here
Most of the time we used to download the data onto .csv file from website we can also code the same thing by writing this code
protected void Download_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(“Server=.;uid=sa;pwd=****;database=practice”);
string query = “select * from rnemp;
SqlCommand cmd = new SqlCommand(query, conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable ds = new DataTable();
da.Fill(ds);
string csv = string.Empty;
foreach (DataColumn column in ds.Columns)
{
csv += column.ColumnName + ‘,’;
}
csv += “\r\n”;
foreach (DataRow row in ds.Rows)
{
foreach (DataColumn column in ds.Columns)
{
csv += row[column.ColumnName].ToString().Replace(“,”, “;”) + ‘,’;
}
csv += “\r\n”;
}
Response.Clear();
Response.Buffer = true;
Response.AddHeader(“content-disposition”, “attachment;filename=SqlExport.csv”);
Response.Charset = “”;
Response.ContentType = “application/text”;
Response.Output.Write(csv);
Response.Flush();
Response.End();
}
}
Serialization is the process of converting a object into binary format and store data in a text file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
namespace SerializeExample
{
public partial class Form1 : Form
{
Employee E1 = new Employee();
FileStream fs ;
BinaryFormatter b = new BinaryFormatter();public Form1()
{
InitializeComponent();
}private void Form1_Load(object sender, EventArgs e)
{}
private void button1_Click(object sender, EventArgs e)
{
E1.Eno = int.Parse(textBox1.Text);
E1.Ename = textBox2.Text;
fs = new FileStream(“E:\\Employee.txt”, FileMode.Create, FileAccess.Write);
b.Serialize(fs, E1);
fs.Flush();
fs.Close();
MessageBox.Show(“Serialized”);
textBox1.Text = “”;
textBox2.Text = “”;
}private void button2_Click(object sender, EventArgs e)
{
fs = new FileStream(“E:\\Employee.txt”, FileMode.Open, FileAccess.Read);
E1 = (Employee)b.Deserialize(fs);
fs.Flush();
fs.Close();
textBox4.Text = E1.Eno.ToString();
textBox3.Text = E1.Ename;
MessageBox.Show(“Deserialized”);
}
}
}
ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework.
When you’re building APIs on the Web, there are several ways you can build APIs on the Web. These include HTTP/RPC, and what this means is using HTTP in Remote Procedure Call to call into things, like Methods, across the Web.
The verbs themselves are included in the APIs, like Get Customers, Insert Invoice, Delete Customer, and that each of these endpoints end up being a separate URI.
Let’s take a look at a simple example of Web API by creating a new ASP.NET Web Application.
Step 1 – Open the Visual Studio and click File → New → Project menu option.
A new Project dialog opens.
Step 2 – From the left pane, select Templates → Visual C# → Web.
Step 3 – In the middle pane, select ASP.NET Web Application
Enter project name WebAPIDemo in the Name field and click Ok to continue. You will see the following dialog, which asks you to set the initial content for the ASP.NET project.
Step 4 – To keep things simple, select the Empty option and check the Web API checkbox in the ‘Add folders and core references for’ section and click Ok.
Step 5 – It will create a basic MVC project with minimal predefined content.
Once the project is created by Visual Studio, you will see a number of files and folders displayed in the Solution Explorer window.
Step 6 – Now we need to add a model. Right-click on the Models folder in the solution explorer and select Add → Class.
You will now see the Add New Item dialog.
Step 7 – Select Class in the middle pan and enter Employee.cs in the name field.
Step 8 – Add some properties to Employee class using the following code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WebAPIDemo.Models {
public class Employee{
public int ID { get; set; }
public string Name { get; set; }
public DateTime JoiningDate { get; set; }
public int Age { get; set; }
}
}
Step 9 – Let’s add the controller. Right-click on the controller folder in the solution explorer and select Add → Controller.
It will display the Add Scaffold dialog.
Step 10 – Select the Web API 2 Controller – Empty option. This template will create an Index method with default action for controller.
Step 11 – Click ‘Add’ button and the Add Controller dialog will appear.
Step 12 – Set the name to EmployeesController and click ‘Add’ button.
You will see a new C# file ‘EmployeeController.cs’ in the Controllers folder, which is open for editing in Visual Studio with some default actions.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using WebAPIDemo.Models;
namespace WebAPIDemo.Controllers{
public class EmployeesController : ApiController{
Employee[] employees = new Employee[]{
new Employee { ID = 1, Name = "Mark", JoiningDate =
DateTime.Parse(DateTime.Today.ToString()), Age = 30 },
new Employee { ID = 2, Name = "Allan", JoiningDate =
DateTime.Parse(DateTime.Today.ToString()), Age = 35 },
new Employee { ID = 3, Name = "Johny", JoiningDate =
DateTime.Parse(DateTime.Today.ToString()), Age = 21 }
};
public IEnumerable<Employee> GetAllEmployees(){
return employees;
}
public IHttpActionResult GetEmployee(int id){
var employee = employees.FirstOrDefault((p) => p.ID == id);
if (employee == null){
return NotFound();
}
return Ok(employee);
}
}
}
Step 13 – Run this application and specify /api/employees/ at the end of the URL and press ‘Enter’. You will see the following output.
Step 14 – Let us specify the following URL http://localhost:63457/api/employees/1 and you will see the following output.

Code for this can be here
Good Morning!!!…
I think most of us will use to sign in to atleast one website per day .when we enter the name in box the text we entered will be displayed by right side or below.

Here is how it looks like.

For code click here
Good Evening Decoders!!!!. As u are aware that nearly 600k websites are being launching everyday. Jobs for techies were growing in proportionally to them. Somehow company were testing the fresher fellows with codebytes. Here is the task to create a HTML table using rowspan and colspan elements .Like Below

Code will be like below :

You can get code by clicking Here .
Constraints
Constraints are used to apply conditions or restrictions on Database objects like the tables
Different types of constraints are:
1.Null.
2.Not Null.
3.Primary key constraint.
4.Unique key constraint.
5.Foreign key Constraint.
6.Checked Constraints.
7.Composite primary key Constraint.
8.Default Constraints.
9.Unique +Not Null constraint.
Null constraint
If we apply null constraint for a column then column will allow null values.By default every column will allow null values.
Syntax to apply null constraint at the time of creating table.
Create table emp(eno int null,ename vacharu(30)).
Not Null Constraint
If will not allow null values.
Syntax
Create table tablename(colname datatype not null).
Ex:create table e1(eno int not null,ename vacharu (50),salary money).
syntax to apply the not null constraint after creating the table
alter table tablename alter column column name datatype not null.
Primary key.
Primary key constraint will not allow duplicate values and null values.w e can apply only one primary key Constraint on a table. Primary key Constraint will have constraint name .
Q,why primary key will not allow null values?
Whenever we apply primary key constraint on a column then automatically not null constraint will be added to that column and that not null constraint will not allow null values.
what is the purpose of constraint name?
The purpose of constraint name is to identify the Constraint.if we want to drop the constraint we use constraint name.
synatx to apply primary key constraint at the timeof creating a table.
create table tablename(colname datayp2 primary key).
Ex: create table e2 (eno int primary key ,ename vacharu(50).
syntax 2
Create table tablename (colname datatype constraint Constraintname primary key).
create table e3(eno int constraint pk_e3_eno primary key,ename vacharu(50)).
Syntax to apply primary key constraint after creating the table.
create table e4(eno int ename vaechar (50)
.1,alter table e4 add primary key(eno).
Here:error will be generated because of table column eno allows null values .so first make it as not null type.
alter table e4 alter column eno int not null
Can we apply primary key of nullable column.
No.
.2, syntax 2
Alter table tablename add constraint Constraintname primary key(colname).
syntax to drop primary key ..
alter table tablename drop constraint Constraintname.
Ex:alter table e3 drop constraint pk_e3_eno
Unique key constraint.
Unique key constraint will not allow duplicate values.
unique key constraint will allow null values. Unique constraint will not allow two null value ,that is it will allow only one null value..
We can apply more than one unique constraint on a single table .
synatx to apply unique key at the timeof table creation.
create table tablename (colname datatype unique).
create table e5(eno int unique,ename vaechar(50).
syntax to apply unique key after table creation .
alter table tablename add unique (colname)