Posts

Showing posts with the label ASP.NET

ASP.NET master pages & site Navigation Example

Image

How to make databse connectivity in ASP.NET?

Please add the follwoing code in you sample.cs page. Step 1 : Add Namspace "using System.Data.SqlClient;" Step 2 : Make Sql connection. SqlConnection con = new SqlConnection("Server=You server name or comp name; Database=Yourdatabasename;Trusted_Connectopn=True"); SqlCommand cmd = new SqlCommand("select * from Table name"); con.Open(); DataSet ds = new DataSet(cmd,con); SqlDataAdapter da = new SqlDataAdapter(); da.Fill(ds); con.Close();

session state

<sessionState mode=”SQLServer” stateConnectionString=”tcpip=192.168.1.1:42424" sqlConnectionString=”data source=192.168.1.1; Integrated Security=SSPI” cookieless=”false” timeout=”20" />

Web.Config Setting

<configuration> <appSettings> <add key="ConnectionString" value="server=abc;pwd=password;database=TEST" /> </appSettings> This is global configuration setting for database.This setting you can use any  page.

ASP.NET Life Cycle

Page_Init --> LoadViewState --> LoadPostData --> Page_Load --> RaisePostDataChangedEvent --> RaisePostBackEvent --> Page_PreRender --> SaveViewState --> Page_Render --> Page_UnLoad Page_load Event guarantees that all controls are fully loaded. In  Page_Init events controls are also accessed but you will see that view state is not fully loaded during this event.

Abstract Class and Interface

Abstract classes can have concrete methods while interfaces have no methods implemented. Interfaces do not come in inheriting chain, while abstract classes come in inheritance