When an aspx requested, IIS checks the file extension in its metabase.
To view the metabase Start> Run > inetmgr
In the Internet Information Services window right click in 'Web sites' > Properties
Select 'Home Directory' tab and click the Configuration button
Now you can see a table with 3 columns.
aspx is mapped to aspnet_isapi.dll
When IIS find the extension aspx, then it loads the aspnet_isapi.dll and pass all the request details to it.
aspnet_isapi.dll then loads the CLR and pass all the request details that received.
CLR then create HttpRuntime engine.
The begining of the runtime engine is HttpRunTime class. It creates the HttpContext object and stores all the request details.
From there HttpContext object passes through a pipeline which consists of HttpApplication object, HttpModule objects and finally HttpHandler object ( that is our page class).
HttpHandler object creates the html page
Hope so you get ur answer
Thursday, October 14, 2010
Friday, September 3, 2010
How to SAVE and RETRIEVE image in DataBase SQL with LINQ
public void SaveImage()
{
byte[] pic = null;
int len = FUImage.PostedFile.ContentLength;
pic = new byte[len];
FUImage.PostedFile.InputStream.Read(pic, 0, len);
Table_Name tab_name = new Table_Name()
{
Image = pic,
};
_data.odatacontext.Table_Name.InsertOnSubmit(tab_registration);
_data.odatacontext.SubmitChanges();
}
}
public void RETRIEVEImage()
{
try
{
System.IO.MemoryStream stream = new MemoryStream();
SqlConnection connection = new
SqlConnection(@"Data Source=(local);Initial Catalog=DataBaseName;User ID=sa;Password=123");
connection.Open();
SqlCommand command = new
SqlCommand("select top(1) Image from Table_Name order by RID desc", connection);
byte[] image = (byte[])command.ExecuteScalar();
stream.Write(image, 0, image.Length);
System.Drawing.Bitmap bitmap = new Bitmap(stream);
Response.ContentType = "image/gif";
bitmap.Save(Response.OutputStream, ImageFormat.Gif);
}
finally
{
connection.Close();
}
}
{
byte[] pic = null;
int len = FUImage.PostedFile.ContentLength;
pic = new byte[len];
FUImage.PostedFile.InputStream.Read(pic, 0, len);
Table_Name tab_name = new Table_Name()
{
Image = pic,
};
_data.odatacontext.Table_Name.InsertOnSubmit(tab_registration);
_data.odatacontext.SubmitChanges();
}
}
public void RETRIEVEImage()
{
try
{
System.IO.MemoryStream stream = new MemoryStream();
SqlConnection connection = new
SqlConnection(@"Data Source=(local);Initial Catalog=DataBaseName;User ID=sa;Password=123");
connection.Open();
SqlCommand command = new
SqlCommand("select top(1) Image from Table_Name order by RID desc", connection);
byte[] image = (byte[])command.ExecuteScalar();
stream.Write(image, 0, image.Length);
System.Drawing.Bitmap bitmap = new Bitmap(stream);
Response.ContentType = "image/gif";
bitmap.Save(Response.OutputStream, ImageFormat.Gif);
}
finally
{
connection.Close();
}
}
Monday, May 24, 2010
Friday, February 5, 2010
XML with LINQ
Parent child Relationship:
public static object GetMLAMemberDetailsByConstituency(string Id) {
XDocument Xdoc = XDocument.Load("Root.Data/DataXML/MLAXML.xml");
var settingElement = from us in Xdoc.Elements("root").Elements ("State").Elements("PC").Elements("Constituency").Elements("PM").Elements("PT")
where us.Parent.Parent.Attribute ("ConstituencyId").Value == Id
select new
{
FirstName = us.Parent.Attribute ("FirstName").Value,
LastName = us.Parent.Attribute("LastName").Value,
State = us.Parent.Parent.Parent.Parent.Attribute("StateName").Value,
PC = us.Parent.Parent.Parent.Attribute("PCName").Value,
constituency = us.Parent.Parent.Attribute("ConstituencyName").Value,
ConstituencyId = us.Parent.Parent.Attribute("ConstituencyId").Value,
PartyName = us.Attribute("PartyName").Value,
};
return settingElement.ToList();
}
More Details:
http://www.aspnettutorials.com/tutorials/xml/linq-to-xml-adding-cs.aspx
public static object GetMLAMemberDetailsByConstituency(string Id) {
XDocument Xdoc = XDocument.Load("Root.Data/DataXML/MLAXML.xml");
var settingElement = from us in Xdoc.Elements("root").Elements ("State").Elements("PC").Elements("Constituency").Elements("PM").Elements("PT")
where us.Parent.Parent.Attribute ("ConstituencyId").Value == Id
select new
{
FirstName = us.Parent.Attribute ("FirstName").Value,
LastName = us.Parent.Attribute("LastName").Value,
State = us.Parent.Parent.Parent.Parent.Attribute("StateName").Value,
PC = us.Parent.Parent.Parent.Attribute("PCName").Value,
constituency = us.Parent.Parent.Attribute("ConstituencyName").Value,
ConstituencyId = us.Parent.Parent.Attribute("ConstituencyId").Value,
PartyName = us.Attribute("PartyName").Value,
};
return settingElement.ToList();
}
More Details:
http://www.aspnettutorials.com/tutorials/xml/linq-to-xml-adding-cs.aspx
Sunday, January 24, 2010
AutoComplete Textbox
Introduction:
This article explains to fill a AutoComplete Textbox from the data fetched from database.
Description:
Everyone knows about the AutoComplete Textbox. It is an ASP.NET AJAX extender that can be attached to any TextBox control. When the user types some letters in the Textbox, a popup panel will come to action and displayed the related words. So that the user can choose exact word from the popup panel. Here I tried to explain how this AutoComplete fetches data from the database through a Webservice.
Open Microsoft Visual Studio, click on New Website. Then choose ASP.NET Ajax Enabled Website and change the location to point your http://localhost/AutoComplete folder. Obviously, Default.aspx is added to your solution explorer.
Now drag and drop a Textbox from your Toolbox. Then drag and drop a ScriptManager and AutoCompleteExtender to your Default.aspx page. Then add a webservice to your project as WebService.asmx. First thing you have to do is to add the ScriptService reference to the webserive as follows.
System.Web.Script.Services.ScriptService
[WebMethod]
public string[] GetCountryInfo(string prefixText)
{
int count = 10;
string sql = "Select * from Country Where Country_Name like @prefixText";
SqlDataAdapter da = new SqlDataAdapter(sql,"Your Connection String Comes Here"));
da.SelectCommand.Parameters.Add("@prefixText", SqlDbType.VarChar, 50).Value = prefixText+ "%";
DataTable dt = new DataTable();
da.Fill(dt);
string[] items = new string[dt.Rows.Count];
int i = 0;
foreach (DataRow dr in dt.Rows)
{
items.SetValue(dr["Country_Name"].ToString(),i);
i++;
}
return items;
}
The above webmethod takes prefixText as argument, sends it to the query to fetch only the related words that starts with the prefixText values. Then it returns the result as an array of strings.
Now, it's time to run the project. Select the Default.aspx and click on View in Browser. You can see the excellent application starts to run. Type your country's first letter. See all the countries starts with that letter will appear in the popup.
This article explains to fill a AutoComplete Textbox from the data fetched from database.
Description:
Everyone knows about the AutoComplete Textbox. It is an ASP.NET AJAX extender that can be attached to any TextBox control. When the user types some letters in the Textbox, a popup panel will come to action and displayed the related words. So that the user can choose exact word from the popup panel. Here I tried to explain how this AutoComplete fetches data from the database through a Webservice.
Open Microsoft Visual Studio, click on New Website. Then choose ASP.NET Ajax Enabled Website and change the location to point your http://localhost/AutoComplete folder. Obviously, Default.aspx is added to your solution explorer.
Now drag and drop a Textbox from your Toolbox. Then drag and drop a ScriptManager and AutoCompleteExtender to your Default.aspx page. Then add a webservice to your project as WebService.asmx. First thing you have to do is to add the ScriptService reference to the webserive as follows.
System.Web.Script.Services.ScriptService
[WebMethod]
public string[] GetCountryInfo(string prefixText)
{
int count = 10;
string sql = "Select * from Country Where Country_Name like @prefixText";
SqlDataAdapter da = new SqlDataAdapter(sql,"Your Connection String Comes Here"));
da.SelectCommand.Parameters.Add("@prefixText", SqlDbType.VarChar, 50).Value = prefixText+ "%";
DataTable dt = new DataTable();
da.Fill(dt);
string[] items = new string[dt.Rows.Count];
int i = 0;
foreach (DataRow dr in dt.Rows)
{
items.SetValue(dr["Country_Name"].ToString(),i);
i++;
}
return items;
}
The above webmethod takes prefixText as argument, sends it to the query to fetch only the related words that starts with the prefixText values. Then it returns the result as an array of strings.
Now, it's time to run the project. Select the Default.aspx and click on View in Browser. You can see the excellent application starts to run. Type your country's first letter. See all the countries starts with that letter will appear in the popup.
Thursday, January 21, 2010
SqlCacheDependency Caching in Detail
Caching with filtration:
private void Bind()
{
try
{
DataSet DS_district = new DataSet();
DataTable _table = new DataTable();
if (Cache["CachingName"] == null)
{
DS_district = Common.GetAllDistrict();
SqlCacheDependency dependency = new SqlCacheDependency ("DataBaseName", "TableName");
Cache.Insert("CachingName", DS_district, dependency, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(10));
_table = DS_district.Tables[0];
var query = from _district in _table.AsEnumerable()
where _district.Field
select _district;
DataView _view = query.AsDataView();
Dropdown1.DataSource = _view;
Dropdown1.DataTextField = "Name";
Dropdown1.DataValueField = "Id";
Dropdown1.DataBind();
}
else
{
DS_district = (DataSet)Cache["CachingName"];
_table = DS_district.Tables[0];
var query = from _district in _table.AsEnumerable()
where _district.Field
select _district;
DataView _view = query.AsDataView();
Dropdown1.DataSource = _view;
Dropdown1.DataTextField = "GeographicName";
Dropdown1.DataValueField = "GeographicId";
Dropdown1.DataBind();
}
}
catch (Exception ex)
{
lblError.Text = ex.Message.ToString();
}
}
Thursday, January 7, 2010
Implement Caching
In SQL Server DataBase:
Run this command:
Exp:
aspnet_regsql.exe -S localhost -U sa -P sa -d NewDataBase -ed
This command Enable your Data Base, now You need to enable using table , for this command is...
aspnet_regsql.exe -S localhost -U sa -P sa -d NewDataBase -t tableName -et
After this go to SQL server , you get a new table "AspNet_SqlCacheTablesForChangeNotification".
coding on web.conf file
system.web
caching
sqlCacheDependency enabled="true"
databases
add name="NewTest" connectionStringName="Connection" pollTime="500"
/databases
/sqlCacheDependency
/caching
/system.web
Coding on .cs file
DataSet geography = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
try
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ConnectionString);
SqlDataAdapter adapter = new SqlDataAdapter("Select * from Users", conn);
adapter.Fill(geography);
SqlCacheDependency dependency = new SqlCacheDependency("NewTest", "Users"); Cache.Insert("Geo", geography, dependency,System.Web.Caching.Cache.NoAbsoluteExpiration,TimeSpan.FromMinutes(20));
GridView1.DataSource = geography;
GridView1.DataBind();
lblMessage.Text = "Categories retrieved from the Data Base";
}
catch { }
}
}
protected void Button1_Click(object sender, EventArgs e)
{
DataSet ds = (DataSet)Cache["Geo"]; lblMessage.Text = "Categories retrieved from the Cached data base";
GridView1.DataSource = ds;
GridView1.DataBind();
}
Subscribe to:
Posts (Atom)