Friday 10 August 2012

Ajax UpdateProgress Example

You can use UpdateProgress control to show while application is processing user's request. You can get it From Toll box under Ajax Extensions Tab. I am describing you a scenario:

Suppose I have One Upadate Panel name UpdatePnl1 , In that I have a Button Say GO.when we hit on go it should redirect to another page. before that it will promt you "please wait".

Now my Code will be like that

<asp:UpdatePanel ID="UpdatePnl1" runat="server">
<ContentTemplate>
<asp:Button ID="BtnGO" runat="server" Text="GO" onclick="BtnGO_Click"/>
</ContentTemplate>
</asp:Updatepanel>
 
Button click event code:

 protected void BtnGO_Click(object sender, EventArgs e)
    {
        Response.Redirect("Example.aspx");
    }
 
Now here is the code for UpdateProgress what you need to add

<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePnl1" >
      <ProgressTemplate>

      <asp:Label ID="LblWaitMsg" runat="server" Text="Processing Request, Please Wait...">
</asp:Label>           

       </ProgressTemplate>
 </asp:UpdateProgress>
 
Note: Your page Should contain ScriptManager. 

What is Hibernate and N-Hibernate?

Below I mentioned a brief introduction of Hibernate and N-Hibernate.

Hibernate:

Hibernate is an object-relational mapping (ORM) library for the Java language, providing a framework for mapping an object-oriented domain model to a traditional relational database. Hibernate solves object-relational impedance mismatch problems by replacing direct persistence-related database accesses with high-level object handling functions.
Hibernate is free software that is distributed under the GNU Lesser General Public License.
Hibernates primary feature is mapping from Java classes to database tables (and from Java data types to SQL data types). Hibernate also provides data query and retrieval facilities. It also generates the SQL calls and attempts to relieve the developer from manual result set handling and object conversion and keep the application portable to all supported SQL databases with little performance overhead.
For more details please visit: http://www.hibernate.org/

N-Hibernate:

N-Hibernate is an object-relational mapping (ORM) solution for the Microsoft .NET platform: it provides a framework for mapping an object-oriented domain model to a traditional relational database. Its purpose is to relieve the developer from a significant portion of relational data persistence-related programming tasks. NHibernate is free as open source software that is distributed under the GNU Lesser General Public License. NHibernate is a port of the popular Java O/R mapper Hibernate to .NET.
For more details please visit: http://nhforge.org/

Thursday 9 August 2012

How to bind Listbox using Dataset

Below Is the ListBox markup in script.


And see the below C# code for data bind. Here LoadContact() is the method I am using for binding the ListBox.


Now need to call LoadContact() from page_Load(). See the code below.



Note: The code is getting Connection String from web.config. So below is the example of Connection String in web.config.

 

And Here we Go


What is DataReader and DataSet

ADO.Net Offers two objects to Read data from the Data source. One is DataReader and Another one is DataSet.

DataReader

DataReader is an object used for reading data sequentially. The DtaReader is Read-Only,That means you can not modify data using DataReader. You can read the data in forward-only manner. DataReader can read one record at a time. The forward only design enables Data access faster.

NameSpace to use DataReader

System.Data.SqlClient      /*For SqlServer*/
System.Data.OleDb          /*For OleDb Connection*/
System.Data.OracleClient   /*For Oracle*/

Example of DataReader

 

 

DataSet

DataSet is a core of ADO.Net disconnected architecture and is used to store data in a disconnected state. It's actually a collection of one or more data objects, Usually presented in tabular format. It's Fully supports XML so that XML document can be read into DataSet or a DataSet can be exported to XML.

NameSpace to use DataSet

System.Data

DataSet Architecture

 

Example of DataSet