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 3 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.

This is default featured slide 5 title

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

Showing posts with label ASP.Net. Show all posts
Showing posts with label ASP.Net. Show all posts

Tuesday, October 16, 2012

Introduction To ASP.NET


ASP.NET INTRODUCTION

ASP.NET is a web application framework developed and marked by Microsoft to allow programmers to build dynamic websites, web application  and web services. It was first released in January 2002 with version 1.0 of the .NET framework, and it is successor to Microsoft’s Active Server Pages(ASP) technology. ASP.NET  is built on the Common Language Runtime(CLR) allowing programmers to write ASP.NET code using any supported .NET language.

Advantages Of ASP.NET
  • Separation Of Code From HTML :- 
                                                                    To make a clean sweep, with ASP.NET we have  the ability to completely separate layout and business logic. This makes it much easier for teams of programmer and designers to collaborate efficiently.
  • Support For Compiled Languages :-
                                                                   Developer can use VB.NET and access features such as strong typing and object – oriented programming. Using compiled languages also means that ASP.NET pages do not suffer the performance penalties associated with interpreted code. ASP.NET pages are pre-compiled to byte-code and Just In Time(JIT) compiled when first requested Subsequent request are directed to the fully compiled code, which is cached until the source changes.
  • Use Services Provided By The .NET Framework :-
                                                                    The .NET Framework provides class libraries that can be used by our application. Some of the key classes  help us with input/output, access to operating systems services, data access  or even debugging.
  • Graphical Development Environment :-
                                                                   Visual Studio.NET provides a very rich development environment  for web developers. You can drag and drop controls and set properties the way we do in Visual Basic and we have full IntelliSense support, not only for our code, but also for HTML and XML.
  • State Management :-
                                          To refer the problem mentioned before, ASP.NET provides solutions for session and application state management. State information can, for example, be kept in memory or stored in a database. It can be shared across Web farms, and state information can be recovered, even if the server fails or the connection breaks down.
  •  Update Files While The Server Is Running :-
                                                                      Components of our application can be updated while the server is online and clients  are connected.  The Framework will use the new files as soon as they are copied to the application. Removed or old files that are still in use are kept in memory until the clients have finished.
  • XML-Based Configuration Files :-
                                                                  Configuration  settings in ASP.NET are stored in XML files that we can easily read and edit. We can also easily copy these to another server, along with the other files that comprise our application.

Sunday, August 28, 2011

Cookies In Client Side asp.net with C#


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.Cookies["Username"] != null)
Txtusername.Text = Response.Cookies["Username"].Value;
Txtusername.Attributes.Add("value", Request.Cookies["Username"].Value);
if (Request.Cookies["password"] != null)
Txtpassword.Attributes.Add("value", Request.Cookies["password"].Value);
if ((Request.Cookies["username"] != null) && (Request.Cookies["password"] != null))
Chkrember.Checked = true;
}
}
protected void Btnsubmit_Click(object sender, EventArgs e)
{
if ((this.Chkrember.Checked))
{
if ((Request.Browser.Cookies))
{
Response.Cookies["username"].Value = Txtusername.Text;
Response.Cookies["username"].Expires = DateTime.Now.AddYears(20);
Response.Cookies["password"].Value = Txtpassword.Text;
Response.Cookies["password"].Expires = DateTime.Now.AddYears(20);
}
else
{
Response.Cookies["username"].Expires = DateTime.Now.AddYears(-20);
Response.Cookies["password"].Expires = DateTime.Now.AddYears(-20);
} }
}



How can I bind to a DataSet?
DataSet ds = GetDataSet();
DataView view = ds.Tables[0].DefaultView;
SmoothLineChart chart = new SmoothLineChart();
chart.Legend = "Value 1";
chart.DataSource = view;
chart.DataXValueField = "Description";
chart.DataYValueField = "Value1";
chart.DataBind();
ChartControl1.Charts.Add(chart);
ChartControl1.RedrawChart();

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
LoadChartData();
}
}


private void LoadChartData()
{
string constr = @"Server=TestServer; Database=SampleDatabase; uid=sa; pwd=123;";
string query = "SELECT c.CategoryID, c.CategoryName, " +
" Count(p.UnitPrice) AS 'TotalProducts' " +
" FROM Categories c " +
" INNER JOIN Products p ON c.CategoryID = p.CategoryID " +
" GROUP BY c.CategoryID, c.CategoryName";

SqlDataAdapter da = new SqlDataAdapter(query, constr);
DataTable table = new DataTable();
da.Fill(table);

DataView dv = table.DefaultView;

Chart1.Series["Series1"].Points.DataBindXY(dv, "CategoryName", dv, "TotalProducts");
Chart2.Series["Series1"].Points.DataBindXY(dv, "CategoryName", dv, "TotalProducts");
}

Drop Down List in Multiple Selected Items

For example if u select in country and it will come state and city
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public partial class _Default : System.Web.UI.Page
{
//Class1 obj = new Class1();
private string strconnection = "Data Source=NCORE-8;Initial Catalog=dropdown;Trusted_Connection=true;Integrated Security=True ";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindCountryDropdown();
}
}
protected void BindCountryDropdown()
{
SqlConnection con = new SqlConnection(strconnection);
con.Open();

SqlCommand cmd = new SqlCommand("select * from Country", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
ddlCountry.DataSource = ds;
ddlCountry.DataTextField = "CountryName";
ddlCountry.DataValueField = "CountryID";
ddlCountry.DataBind();
ddlCountry.Items.Insert(0, new ListItem("--Select--", "0"));
ddlState.Items.Insert(0, new ListItem("--Select--", "0"));
ddlCity.Items.Insert(0, new ListItem("--Select--", "0"));

}

protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
{
int CountryID = Convert.ToInt32(ddlCountry.SelectedValue);
SqlConnection con = new SqlConnection(strconnection);
con.Open();


SqlCommand cmd = new SqlCommand("select * from State where CountryID=" + CountryID, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();

da.Fill(ds);
con.Close();

ddlState.DataSource = ds;
ddlState.DataTextField = "StateName";
ddlState.DataValueField = "StateID";
ddlState.DataBind();
ddlState.Items.Insert(0, new ListItem("--Select--", "0"));

if (ddlState.SelectedValue == "0")
{
ddlCity.Items.Clear();
ddlCity.Items.Insert(0, new ListItem("--Select--", "0"));
}
}


protected void ddlState_SelectedIndexChanged(object sender, EventArgs e)
{
int StateID = Convert.ToInt32(ddlState.SelectedValue);
SqlConnection con = new SqlConnection(strconnection);
con.Open();

SqlCommand cmd = new SqlCommand("select * from City where StateID=" + StateID, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();

da.Fill(ds);
con.Close();

ddlCity.DataSource = ds;
ddlCity.DataTextField = "CityName";
ddlCity.DataValueField = "CityID";
ddlCity.DataBind();
ddlCity.Items.Insert(0, new ListItem("--Select--", "0"));
}
}

Webconfig




App code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;

///


/// Summary description for Class1
///

public class Class1
{
public string CountryName, StateName, CityName , cs;
public int CountryId, StateID, CityID;
public Class1()
{
cs = System.Configuration.ConfigurationManager.AppSettings["Connection"].ToString();
}


}