Page navigation techniques in asp.net-Hyperlink


Page Navigation


In this part we will study what is page navigation technique? Why use them? Basically there are different types of page navigation technique in ASP.NET but each technique has its own importance and benefits, and which page-navigation technique should be used depends on the current scenario of the application.

Page Navigation technique in the ASP.NET
1. HyperLink Control
2. Rsponse.Redirect
3. Server.Execute
4. Cross Page PostBack
5. Window.Open

Page-Navigation use to navigate a page by suggested path. Not only you navigate a page you can also apply website navigation.

In real time in web application we need to navigate a page from one page to another page, but if not properly navigate than through an error at runtime (like 404 error).

Hyperlink


The easiest way to navigate from one web page to another web page with an ASP.NET hyperlink control.

Hyper link control maintain the history, Hyper link control is a like html anchor tag, which is use to navigate same web-server or different server.

Hyperlink does not expose server side events, so when user click on a HyperLink, there is no server side event to intercept the click where button click event is intercept.

We create Page-Navigation.aspx page in ASP.NET and drag and drop HyperLink control in this page from toolbox.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page-Navigation.aspx.cs" Inherits="AspDotNets.Page_Navigation" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
      <asp:HyperLink ID="hyperlink1" runat="server" NavigateUrl="~/Default.aspx" Text="Navigate to another page"></asp:HyperLink><br/>
<a href="~/Default.aspx" title=""> Navigate to another page</a>
    </form>
</body>
</html>
You can see in the above example we link Default.aspx page in the NavigateUrl property.

We also developed an anchor tag (a href link), which also move to the same page (Default.aspx) when click on anchor tag as we said above hyperlink control of ASP.NET is similar to anchor tag of html.

We create another webform to which we want to navigate through Hyperlink and we name it Default.aspx.

In the above example we show, this is the one of the simple and good website (paste link of website path in navigateUrl) or page navigation method through which we simply navigate a page from one page to another page.



difference between tier and layer architecture in ASP.NET


Before understand difference between n/3 tier architecture in asp.net or n/3 layer architecture we have to understand first of all what is Tier and What is layer?

Layer and Tier


The layers reside on the same machine where the tiers can reside on different machines i.e. an individual running server is one tier, which may mean different assemblies such as DLL, EXE, etc. on the same server or multiple servers, that means we can say that Layer is logical separation of code and Tier is physical separation of code i.e. Tiers are the physical deployment of layers. In other words we can say that Tier Architecture is a physical structuring system where as Layer Architecture is a logical structuring system.

Layer is a good way to achieve tier architecture. Layer and tier may or may not exactly match each other. Each layer may run in an individual tier. However, multiple layers may also be able to run in one tier.

Layer communicates with each other either by Value or by Reference while tier communicate by Value only – as serialized objects.

The 3/n-layer/Tier application has mainly three layers.
1. Presentation Layer
2. Business Logic Layer
3. Data Access Layer

Presentation Layer


The Presentation Layer is basically responsible for displaying the user interface page like ASP.NET, ASPX pages, user controls, html page to the end user, So it is very important layer for getting user data and pass to Business Logic Layer for further operation, and when data is received in Value Object then it’s responsible to represent value object in the appropriate form which user can understand easily.

Business Logic Layer


The Business Logic Layer (BLL) is basically contains all the calculations and business rule that are required in the development of the application. C# business logic layer act as a bridge between Presentation Layer and data Access layer. In this layer the all the functionality that get data from the Presentation Layer and send that data to database through Data Access Layer.

Data Access Layer


The Data Access Layer (DAL) is basically gets the data from the business layer and sends it to the database or vice versa. DAL is responsible for accessing data and forwarding it to BLL. In an ASP.NET n­Tier architecture, web pages do not make direct access to the database

prestation-layer-bussiness-layer-data-access-layer-architecture
3/n- Layer/Tier Architecture
 Advantage:-

1. Presentation layer can only access the public components in application layer, but not in data layer where as Application layer can only access the public components in data layer, but not in presentation layer. This process can minimize the dependencies of layers on each other and provide finer security control to the whole system.

2. Since each layer are independent so it is easy to change one database storage too another database storage like from MS SQL Server to oracle.

3. Suppose we need to change some change in business access layer than no need to change in data access layer i.e. if we change in business layer than data layer no effect.

e.g. recently The Indian Govt. change our Tax system, than Indian Govt. only need to update business logic system without changing or affecting in the other system.

Disadvantages:-

1. If we use n- tier application in our project, we know it has great advantage but still it has some disadvantage, the performance of the entire system may be slow if the hardware and network, computers and processes aren’t good enough for the system.

2. Cost of the entire System may be hike because more hardware, network system involved..

3. Maintenance and deployment of the system become difficult because more hardware and better network bandwidth are needed for deployment and maintenance.

Note:-
All above layers are able to run in three separate computers. Practically, these three layers can also be deployed in one computer ﴾3‐Tier architecture, but deployed as 1‐Tier﴿.

3-Layer:-

In 3 layer architecture , the Database Access Layer (DAL), Business Logic Layer (BLL) and User Interface Layer (UIL) resides as 3 different project and the output of these 3 projects must be together in the same server or on same machine in order for the system to run.
In 3 layer architecture DAL, BLL and UIL can work on same machine.

3-Tier:-

In three tier architecture the Database Access Layer (DAL), Business Logic Layer (BLL) and User Interface Layer (UIL) reside as 3 different projects. But each of the projects can be deployed at the different server or at the different machines and distributed functionality is explored.

In three tier architecture in asp net c# a client in on one machine, the application Server is hosted in another machine and the database server resides in another machine i.e. Three-tier is a client–server architecture in which the User Interface, Business Logic , Data Storage and Data Access are developed and maintained as independent modules on separate platforms.

N-Tier:-

We hear a lot of time about c# n tier architecture even some of us read or use N‐Tier architecture for many time but still misunderstand its concepts of it. In this part we tries to clarify many basic concepts in N‐Tier architecture and we will also provide some industry based examples in the next parts.

N-tier architecture is probably one of the most used architecture models in the usually use in industry software architecture model, N-tier supports client/server applications by solving many points like scalability, security, extensible, secure and maintainable, over time, functionality and many more which helps the developers with different roles to better do their job without interfering with each other.

Visual studio have no pre‐defined tools or process that tell how to implement or solve the N-Tier architecture so it is very necessary to understand full concept of N-Tier before implementation.

N‐tier data applications are data applications that are separated into multiple tiers. Also called distributed applications and multitier applications. N‐tier application includes a presentation tier, a middle tier, and a data tier.

During Development of the n tier application or n layer application we need to keep in mind some points which are given below.

1.   All Application tier or layer must be independent to each other.

2.   Each component and module must be responsible for specific feature or functionality.

3.   Each functionality must be define once in the application

4.   Your application must be developed as like whenever you need to add new layer/tier or change technology you can implement easily.

5.   Most important point to remember must set some coding standard, Each developer has own standard coding style.

image flip using css and html


In this part we will study how to image flip using html and css. In this part when we hover on the images will be show animation using css3 transition animation. We can set transition effect as we have required. For apply flip image code, we need to create html page and a css page first and link the css page to html page in the head section of html page as show below in the code.

Example 1
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
<div id="div-container">
            <div id="card">
                <div class="front-img face-img">
                    <img src="image/maa-sharda-technology-img.jpg" height="200px" width="200px" />
                </div>
                <div class="back-img face-img">
                    <p>Subscribe on google pluse our blog for more updates.</p>
                    <p>like our facebook page</p>
                    <p>Follow us on twitter.</p>
                </div>
            </div>
        </div>
</body>
</html>
How to write code.
First create two div (here we create front-img & back-img class) and put these div inside the another div (we create card) than this div “card” put inside parent div (we create div-container) now write html code in both div (front-img & back-img) as show above for css 3d animation.
Now we create css style sheet.

Flip-image-css.css
#div-container {
  position: relative;
  margin: 10px auto;
  width: 200px;
  height: 200px;
  z-index: 1;
}
#div-container {
  perspective: 1000;
}
#card {
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: all 1.0s linear;
}
#div-container:hover #card {
  transform: rotateY(180deg);
}
.face-img {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
}
.face-img.back-img {
  display: block;
  transform: rotateY(180deg);
  box-sizing: border-box;
  padding: 10px;
  color: white;
  text-align: center;
  background-color: #F7C322;
}
As seen above in the code we set in one front image and in the other front set text but we can set in the front and back images on both sides.

NOTE:- You can set also image instead of text paragraph in the back div.

In the below code we set images at both side, and inside css in the style code we link both child div with parent div.

Example 2

Now we create flip-image.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="flip-image-css.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="div-container">
             <div class="flip3d">
            <div class="back">
                <img src="image/maa-sharda-technology-img.jpg" height="200px" width="200px" />
            </div>
            <div class="front">
                <img src="image/M-S-technology-img.jpg" height="200px" width="200px" />
            </div>
        </div>
        </div>
</body>
</html>
How to write code
First create two div (here we create front-div & back-div class) and put these div inside the parent div (we create flip-div). than write html code in both div as show above for css 3d animation.

Now we write css style sheet code.
Flip-image-css.css
#div-container {
    margin: 10px auto;
    width: 200px;
    height: 200px;
}

.flip3d {
    width: 200px;
    height: 200px;
    float: left;
    margin: 10px;
    padding: 10px;
    outline: 2px solid black;
}

    .flip3d > .front {            
        position: absolute;
        transform: perspective(1000px) rotateY(0deg);
        width: 200px;
        height: 200px;
        border-radius: 7px;
        backface-visibility: hidden;
        transition: transform .5s ease-in 0s;
        outline: 2px solid rgba(0,0,100,0.7);
        border-spacing: 5px;
    }

    .flip3d > .back {
        position: absolute;
        transform: perspective(1000px) rotateY(-180deg);
        width: 200px;
        height: 200px;
        border-radius: 7px;
        backface-visibility: hidden;
        transition: transform .5s ease-in 0s;
        outline: 2px solid green;
    }

    .flip3d:hover > .front {
        transform: perspective(200px) rotateY(180deg);
    }

    .flip3d:hover > .back {
        transform: perspective(200px) rotateY(0deg);
    }

Query String using 3-layer architecture


QueryString through 3-layer architecture


In the ASP.NET beginners part we learned about how QueryString transfer data from one page to another page through URL. In this Part we will learn how transfer data using 3-layer architecture by use of QueryString process.

First of all create tables and store procedure in SQL Server 2008.
--We Create table tblNews

create table tblNews
(
 NewsId int identity(1,1) not null primary key,
 NewsTitle varchar(300) Not Null,
 NewsDisc varchar(500) Null,
 NewsDisc_Text text Null,
 PostedDate date Not Null constraint tblNews_PostedDate default(getdate()),  --get current date/time by use default constraint 
 ModifyDate date Not Null constraint tblNews_ModifyDate default(getdate()),
 IsActive bit Not Null constraint tblNews_IsActive default(0),               --set default 0 
 NewsUrl varchar(500) Null
)

--insert datas into tblNews

Insert into tblNews(NewsTitle,NewsUrl) values('Bollywood','www.web-designing-developing-tutorials.in')
Insert into tblNews(NewsTitle,NewsUrl) values('Bollywood','www.web-designing-developing-tutorials.com')
Insert into tblNews(NewsTitle,NewsDisc,NewsDisc_Text,NewsUrl,IsActive) 
            values('News Title 3','Lorem Ipsum is simply dummy text of the printing and typesetting industry.....','Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s.', 'www.maashardatechnology.in',1)

--you can similar Insert more rows

We have following data into the table.
data-of-table-for-qury-string
Data for QueryString

Now create procedure of the table.
--We create procedure for tblNews tables.

create proc sp_tblNews 
@NewsId int=0,           @Action varchar(50)=null
As 
 Begin
  if(@Action ='SelectAllActiveNews')    --select all active news i.e IsActive=1 
    begin
      select NewsId, NewsTitle, NewsDisc, NewsDisc_Text,
      CONVERT(varchar(20),PostedDate, 107)As [PostedDate] ,   --107 is style like June 30, 2017. you can visit for more style
      CONVERT(varchar(20),ModifyDate, 107)As  ModifyDate, NewsUrl 
      from tblNews where IsActive=1 
      order by NewsId desc
    end
  Else if(@Action='SelectNewsById')     --select news by Id
    begin
      select NewsTitle, CONVERT(varchar(20),PostedDate, 107)As [PostedDate] ,
      NewsDisc_Text from tblNews where IsActive=1 and NewsId= @NewsId;
    end
 End
Open Asp.net, click on File menu than select New:-> Project, Enter project Name as you wish (We enter Blog), Next select location (where you want to save project Name), solution Name automatically set (which is enter in Name).
Create-solution-file-in-ASP.NET
Create solution in ASP.NET

First of all Open Server Explorer from View Menu or press Ctrl+W+L than Right Click on Data Connection in server Explorer window, than click on Add Connection which open Select/change Data Source window than select Microsoft SQL Server than ok, which again open new window than select Server name from DropDownlist (if not show Server name than copy server name from SQL Server and paste) than select database than click Ok.

Step Process
Press Ctrl+W+L :-> Right Click on Data Connection in server Explorer window :-> Add Connection :-> Microsoft SQL Server :-> Ok :-> select Server name :-> select database :-> Ok.
make-connection-in-ASP.NET-with-SQL-Server
Make connection in ASP.NET with SQL server


Now in web Config file write connection string code.
<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
  <customErrors mode="Off"/>
  </system.web>
  <connectionStrings>                     <!---Make connection string with database-->
    <add name="ConStr" connectionString="Data Source=RKSHARMA\RKSHARMA;Initial Catalog=AspDotNetBasic;Integrated Security=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>
</configuration>

Add App_code, BAL,DAL, file-folder
Set File Folder in asp.net

We have to add file and folder in project as above see in picture
Now add App_code folder by right click on blog project than click on add than click on Add ASP.NET Folder than click on App_code folder. Now Add a Class File by Right Clicking on DAL folder within App_Code folder to access database.

Step Process
Right Click on Blog(My project Name) :-> Add :-> Add ASP.NET Folder :-> App_Code :-> Add Folder DAL within App_code :-> Right Click on DAL folder :-> Add :-> Add New Item :-> Class Library File (Class.cs) :-> Name it (DAL.cs) :-> ok.

DAL.cs
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

namespace MaaShardaTechnology.DAL          //namespace
{
    public class NewsDataAccess
    {
        SqlCommand cmd;          
        SqlConnection _sqlCon;
        SqlDataAdapter da;
        DataSet ds;
        SqlConnection SqlCon   //properties
        {
            get { return _sqlCon; }
            set { _sqlCon = value; }
        }
        public NewsDataAccess()  //constructor
        {
            SqlCon = new SqlConnection();      //Object create
            CreateConnection(ConfigurationManager.ConnectionStrings["ConStr"].ToString());   //Create connection, "ConStr" is connection String  name in web.config file
        }

        public SqlConnection CreateConnection(string connectionstring)     //return type SqlConnection, and pass Connectionstring as parameter 
        {
            SqlCon.ConnectionString = connectionstring;
            return this.SqlCon;
        }
        private void Open_Con()
        {
            if (SqlCon.State == ConnectionState.Closed)   //if connection closed than open connection
                SqlCon.Open();
        }
        private void Close_con()
        {
            if (SqlCon.State == ConnectionState.Open)         //if connection open than close connection
                SqlCon.Close();
        }
        public DataSet GetDataSet(SqlCommand cmd)              //Retrun type is Dataset type, and pass sqlcommand as parameter
        {
            ds = new DataSet();
            cmd.CommandType = CommandType.StoredProcedure;
            ds.Clear();
            cmd.Connection = this.SqlCon;
            da = new SqlDataAdapter(cmd);
            da.Fill(ds);
            return ds;
        }
    }
}
Similarly add a new Class File by Right Clicking on BAL folder within App_Code folder to process Business access.

Step Process
By right click Add Folder BAL within App_code :-> Right Click on BAL folder :-> Add :-> Add New Item :-> Class Library File (Class.cs) :-> Name it (BAL.cs) :-> ok.

BAL.cs
using System.Data.SqlClient;
using MaaShardaTechnology.DAL;              //this namespace for DAL.cs
using System.Data;

namespace MaaShardaTechnology.BAL       //namespace
{
    public class NewsBAL
    {
        SqlCommand cmd;
        NewsDataAccess OBJNDA;
        DataTable dt;
        public NewsBAL()
        {}
        public DataTable GetAllActiveNews()      //return type is datatable
        {
            OBJNDA = new NewsDataAccess();
            dt = new DataTable();
            cmd = new SqlCommand("sp_tblNews");                        //sp_tblNews is store procedure name
            cmd.Parameters.AddWithValue("@Action", "SelectAllActiveNews");       //return Sql command from strore procedure  where action is SelectAllActiveNews.
            dt = OBJNDA.GetDataSet(cmd).Tables[0];  //"GetDataSet(cmd)" call the GetDataSet method from DAL.csand pass sql command as parameter, and store dataset into first table (Tables[0])
            return dt;
        }
        public DataSet GetAllActiveNewsById(string id)     //return type is Dataset
        {
            OBJNDA = new NewsDataAccess();
            cmd = new SqlCommand("sp_tblNews");
            cmd.Parameters.AddWithValue("@Action", "SelectNewsById");
            cmd.Parameters.AddWithValue("@NewsId", id);
            return OBJNDA.GetDataSet(cmd);
        }
    }
}

Now in asp.net get query string process to understand we are adding two pages News.aspx and NewsDetails.aspx.
News.aspx page keep brief detail of all news in order to latest news, when click on heading of news or Read More button it move to new page (NewsDetails.aspx) with that news id using query string, where detail about news show.

News.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="News.aspx.cs" Inherits="News" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <meta name="view-port" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <link href="Style/StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
   <div class="container">
            <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
            <asp:Label ID="lblMsg" runat="server"></asp:Label>
            <asp:UpdatePanel ID="UP1" runat="server">
                <ContentTemplate>
                    <asp:DataGrid ID="DataGrid1" runat="server" AutoGenerateColumns="False">
                        <Columns>
                            <asp:TemplateColumn>
                                <ItemTemplate>
                                    <div class="newdiv">
                                        <h2 class="heading"><a href='NewsDetails.aspx?id=<%# Eval("NewsId") %>'><%# Eval("NewsTitle") %></a></h2>                         <!--bind newsid with a tag, and than bind for dispaly news title. when click on news title move to NewsDetail page with id-->
                                        <span class="date"><%# Eval("PostedDate") %></span>               <!--Eval bind the PostedDate column -->
                                        <div class="para"><%# Eval("NewsDisc") %></div>
                                        <span class="readmore"><a id="lnkbtnReadMore" href='NewsDetails.aspx?id=<%# Eval("NewsId") %>'>Read More..</a></span>
                                    </div>
                                </ItemTemplate>
                            </asp:TemplateColumn>
                        </Columns>
                    </asp:DataGrid>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </form>
</body>
</html>
Now write the code to bind the all the news brief detail in code behind of News.aspx.

News.aspx.cs
using System;
using System.Data;
using MaaShardaTechnology.BAL;       //this namespace for BAL.cs

public partial class News : System.Web.UI.Page
{
    NewsBAL ObjNBal;          
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindNews();         //call News Method
        }
    }
    private void BindNews()
    {
        DataTable dt = new DataTable();
        ObjNBal = new NewsBAL();          //object of the NewsBAL class from BAL.cs
        dt = ObjNBal.GetAllActiveNews();    //call GetAllActiveNews() method from NewsBAL class
        if (dt.Rows.Count > 0)          //check condition number of row in table greater than 0
        {
            DataGrid1.DataSource = dt;        
            DataGrid1.DataBind();        //bind datatable in DataGrid
        }
        else
        {
            lblMsg.Text = "There is no data in rows";
        }
    }
}
Create a page to receive the data from News.aspx

NewsDetails.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NewsDetails.aspx.cs" Inherits="NewsDetails" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <meta name="view-port" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <link href="Style/StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div class="container">
            <div class="newdiv">
                <h2 class="heading"><a><asp:Label ID="lbltitle" runat="server"></asp:Label></a></h2>
                <span class="date"> Posted On:-<asp:Label ID="lbldate" runat="server" ></asp:Label><br /></span>
                <div class="para"><asp:Label ID="lblMsg" runat="server" ></asp:Label></div>
            </div>
        </div>
    </form>
</body>
</html>
Now write the some code in code behind of NewsDeatails.aspx in query string asp net c# to receive the news id after click on heading or Read More button to show detail about news.
NewsDetails.aspx.cs
using System;
using MaaShardaTechnology.BAL;           //namespace for BAL.cs
using System.Data;

public partial class NewsDetails : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindNewsDetail();
        }
    }
    private void BindNewsDetail()
    {
        NewsBAL OBJbal = new NewsBAL();
        DataTable dt = new DataTable();

        string strId = Request.QueryString["id"];    //receive requested QueryString Id, id is here string type because recieve from query
        if (strId != null)                           //if id is not null
        {
            DataSet ds = new DataSet();
            ds = OBJbal.GetAllActiveNewsById(strId);    //call GetAllActiveNewsById() method from NewsBAL class and pass id as parameter
            if (ds.Tables.Count > 0)                 //dataset is collection of table , and table is > 0
            {
                dt = ds.Tables[0];
                if (dt.Rows.Count > 0)                  //Datatable is collection of row , row is > 0
                {
                    lbltitle.Text = dt.Rows[0][0].ToString();   //[0][0] indicate first row first column of table
                    lbldate.Text = dt.Rows[0][1].ToString();     //[0][1] indicate first row second column of table
                    lblMsg.Text = dt.Rows[0][2].ToString();
                }
            }
        }
        else
        {
            Response.Redirect("NewsDetails.aspx?id=1");
        }
    }
}
We are adding StyleSheet.css in style folder to set style of the pages.

Step Process Right Click on Blog(My project Name) :-> Add :-> NET Folder :-> Name it (Style) :-> Right Click on Style folder :-> Add :-> Add New Item :-> StyleSheet.css :-> ok.
StyleSheet.css
body {
}

.container {
    width: 1170px;
    margin: 0 auto;
    border: 1px solid #186433;
}

#DataGrid1 {
    border: 2px solid black;
    width: 1000px;
    margin: 10px auto;
}

.newdiv {
    width: 900px;
    background: #186433;
    margin: 55px auto;
    border: 2px solid red;
    box-shadow: 2px 2px 6px 6px #ccc;
}

h2.heading a {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 20pt;
    font-style: normal;
    color: Red;
    text-decoration: none;
    padding: 0 2%;
}

.date {
    color: black;
    font-size: 18px;
    padding: 0 2%;
}

.para {
    color: #ffffff;
    font-size: 11pt;
    font-family: Arial, Helvetica, sans-serif;
    padding: 2% 2%;
    margin: 0 0 55px 0;
}

.readmore {
    background-color: rgba(24,10,51,0.73);
    float: right;
    margin: 0px 30px;
    padding: 9px 14px;
    position: relative;
    bottom: 46px;
}

.readmore a {
    color: #fff;
    text-decoration: none;
}

.readmore:hover {
    background: #fff;
    color: rgba(24,10,51,0.73);
}

.readmore:hover a { 
color: rgba(24,10,51,0.73);
}

@media only screen and (min-width:970px) and (max-width:1169px) {
    .container {
        width: 970px;
    }

    #DataGrid1 {
        width: 800px;
    }

    .newdiv {
        width: 700px;
    }

    h2.heading a {
        font-size: 18pt;
    }

    .readmore {
        margin: 0px 15px;
    }
}

@media only screen and (min-width:750px) and (max-width:969px) {
    .container {
        width: 750px;
    }

    #DataGrid1 {
        width: 580px;
    }

    .newdiv {
        width: 480px;
    }

    h2.heading a {
        font-size: 18pt;
    }

    .readmore {
        margin: 0px 13px;
    }
}

@media only screen and (min-width:450px) and (max-width:749px) {
    .container {
        width: 450px;
    }

    #DataGrid1 {
        width: 280px;
    }

    .newdiv {
        width: 180px;
    }

    h2.heading a {
        font-size: 16pt;
    }

    .para {
        font-size: 11pt;
        margin: 0 0 50px 0;
    }

    .readmore {
        margin: 0 35px;
    }
}

@media only screen and (max-width:449px) {
    .container {
        width: 269px;
    }

    #DataGrid1 {
        width: 100px;
    }

    .newdiv {
        width: 100px;
    }

    h2.heading a {
        font-size: 16pt;
    }

    .para {
        font-size: 9pt;
    }

    .readmore {
        margin: 0 6%;
    }

        .readmore a {
            font-size: 12px;
        }
}
Now build the project by right click on project or Shift+F6 than run the project by pressing F5.
query-string
Click on Read more or title

Now click on any Read more button or any title which move to next page with id of the news and show all detail of the news.
Querystring-in-asp.net c#

instead of delete trigger in SQL Server using views


To Create INSTEAD OF DELETE Triggers first of all we need to create a table (but we create two table) for which we apply trigger and need another table that hold all activity in main table.
--We create table tblDeparment

create table tblDeparment(
Id int identity(1,1) primary key not null,
DeparmentName varchar(30) not null,
Location Char(8) not null,
DeparmentHead varchar(20) not null
)

--insert data's into tblDeparment

Insert into tblDeparment values('IT','London','Carrie')
Insert into tblDeparment values('HR','Mexico','Toy')
Insert into tblDeparment values('Purchasing','Delhi','Ravi')
Insert into tblDeparment values('Finance','New York','Janie')

--Create table tblEmployee

create table tblEmployee(
Id int identity(1,1) primary key not null,
Name varchar(30) not null,
Gender Char(8) not null,
DeparmentId int null constraint FK_tblEmployee_DeparmentId foreign key(DeparmentId) references tblDeparment(Id)
)

--insert data's into tblEmployee 

insert into tblEmployee values('Jane', 'Female', 1) 
insert into tblEmployee values('Levis', 'Male', 3)
insert into tblEmployee values('Lee', 'Female', Null)
insert into tblEmployee values('Rose', 'Female', 1)
Here we create two table “tblDeparment” and “tblEmployee “ which are inter-connected through Foreign key constraint.
We will apply trigger for these tables.
Now create Views.
create View VwTblEmployeeJoinWithtblDepartment
as
select tblEmployee.Id, Name, Gender, DeparmentName
from tblEmployee
join tblDeparment
on tblEmployee.DeparmentId = tblDeparment.Id

Now create table that hold activity of main table by user.
create table tblAudit
(
Id int primary key identity(1,1) not null,
AuditData nvarchar(500)
) 

We have tables and views are given below with data.
all-tables-for-instead-of-insert-trigger
We have all tables for instead of delete trigger using vies

If we try to delete data from view than not delete show an error multiple base table affects.
try-to-delete-data-from-instead-of-delete-trigger-using-views
Try to delete data from view than show an error

So create the INSTEAD OF DELETE Trigger for “VwTblEmployeeJoinWithtblDepartment”
create trigger trtblEmployeeInsteadOfDeatilByView
ON VwTblEmployeeJoinWithtblDepartment
INSTEAD OF DELETE
As
 BEGIN
     Declare @EmpId int, @EmpName varchar(30), 
             @EmpGender varchar(8), @EmpDepatmentName varchar(20),
             @EmpMessage varchar(200);
     select  @EmpId = D.Id, @EmpName = D.Name, 
             @EmpGender= D.Gender, @EmpDepatmentName= D.DeparmentName
             from deleted D              --Here inserted table keep data which we want insert through view.
      
          If(Not exists(Select id from tblEmployee where id = @EmpId))   --If Alredy Name Exists in Cloumn than through message we can also check by UserName, EmailId etc.
             Begin
              Raiserror('Employee With Id Not Exists in the DataBase.', 16, 1)
              Print 'INSTEAD OF DELETED Triggers in SQL Server not fire.' 
              RollBack
             End
           Else
             Begin
              delete tblEmployee from tblEmployee --delete command 
              join deleted
              on tblEmployee.Id = deleted.Id                         
              insert into tblAudit values('Employee succefully deleted with Id ' + CAST(@EmpId as varchar(5)) + 'in trigger in date' + CAST(Getdate() AS nvarchar(30)))
             End
      
 END

Now delete data from view.
delete from VwTblEmployeeJoinWithtblDepartment where Id=2
Now check tables and view.
select-all-table-after-fire-instead-of-delete-trigger-using-views
select All tables and view after fire trigger

Example 2
For more understand about INSTEAD OF INSERT Trigger by view when multiple base table update so we take another trigger example.
First we create another table that hold all activity of main table done by user.
create table tblAuditDetailsBy
(
  Id int not null Primary key identity(1,1),
  EmpId int Not Null,
  EmpName varchar(30) Not Null,
  EmpGender char(8) Not Null,
  EmpDeparmentName varchar(50) Not Null,
  AuditAction varchar(1000) Not Null,
  ActionTakenBy varchar(50) Not Null,
  AuditTime datetime not null default Getdate(),
  ServerName varchar(100) Not Null,
  ServerInstanceName varchar(100) Not Null
)

Now create the INSTEAD OF DELETE Trigger for “VwTblEmployeeJoinWithtblDepartment”
create trigger trtblEmployeeInsteadOfDeleteByDetailView
ON VwTblEmployeeJoinWithtblDepartment
INSTEAD OF DELETE
As
 BEGIN
     Declare @EmpId int, @EmpName varchar(30), 
             @EmpGender varchar(8), @DeparmentName varchar(50),
             @EmpMessage varchar(300),@AuditAction varchar(2000),
             @ActionTakenBy varchar(100),@AuditTime varchar(50),
             @ServerName varchar(100), @ServerInstanceName Varchar(100);
             
     select  @EmpId=D.Id, @EmpName = D.Name, --delete not only keep id column value, keep all column value for which id we want delete. 
             @EmpGender= D.Gender, @DeparmentName= D.DeparmentName
             from deleted D
      
     If not exists(Select Id from tblEmployee where Id = @EmpId)   --If Id not Exists in Cloumn than through message, you can check other condition like departmentId =1 or Gender=Male, than you can print message you can not delete
       Begin
           Raiserror('Id does not exists', 16, 1)
           Print 'INSTEAD OF DELETED Triggers in SQL Server not fire because Id does not exists'
           RollBack
       End
       Else
          Begin
              delete tblEmployee from tblEmployee --delete command 
              join deleted
              on tblEmployee.Id = deleted.Id                                      
             
             SET @AuditAction='Delete Record'
             SET @ActionTakenBy= SYSTEM_USER
             SET @ServerName = CAST(SERVERPROPERTY('ServerName') as varchar(100))
             SET @ServerInstanceName = CAST(SERVERPROPERTY('MachineName') as varchar)
             insert into tblAuditDetailsBy(EmpId, EmpName, EmpGender, EmpDeparmentName, AuditAction,
                                           ActionTakenBy, AuditTime, ServerName, ServerInstanceName)
                                    values(@EmpId,@EmpName, @EmpGender, @DeparmentName, @AuditAction,
                                           @ActionTakenBy, GETDATE(), @ServerName, @ServerInstanceName)
             PRINT 'Successfully Delete Data with ID= ' + CAST(@EmpId as varchar(5)) + CAST(Getdate() AS nvarchar(30));
             PRINT 'Fired the INSTEAD OF Delete Triggers in SQL Server'
          End
 END
Now delete data from view VwTblEmployeeJoinWithtblDepartment.
delete from VwTblEmployeeJoinWithtblDepartment where Id = 2
instead-delete-trigger-using-views-fire-when-delete-data
Try to delete data from view than fire Instead of delete trigger
Now check tables and view.
instead-of-delete-trigger-using-views



How to get javascript query string in asp.net

In the previous chapter we study how QueryString transfer variable from one page to another page through URL using C# code. In this chapter we will study how to use QueryString through JavaScript to transfer data.
z-test.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="z-test.aspx.cs" Inherits="AspDotNets.z_test" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
     <script type="text/javascript">
         function OpenNewWindowPart57() {
             var Name = document.getElementById("txtName").value;
             var Email = document.getElementById("txtEmail").value;
             window.open('z-test2.aspx?UserName=' + Name + '&EmailId=' + Email, '_blank', 'location=no,resizable=no', true);  //true means not maintain the history if false than maintain history
         }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        Name:<asp:TextBox ID="txtName" runat="server"></asp:TextBox><br />
        Email:<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox><br />
        <input id="btnPart57B" onclick="OpenNewWindowPart57()" type="button" value="Window Open using Html Button"/><br />
        <!--or-->
        <!--<asp:Button ID="btn" runat="server" OnClientClick="OpenNewWindowPart57()" Text="Window Open using Asp.Net Button"/><br />-->
       </form>
</body>
</html>

z-test2.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="z-test2.aspx.cs" Inherits="AspDotNets.z_test2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
     Name:-<asp:Label ID="lblName" runat="server"></asp:Label><br />
     EmailId:-<asp:Label ID="lblEmail" runat="server"></asp:Label><br />

    </form>
</body>
</html>

z-test2.aspx.cs
using System;

namespace AspDotNets
{
    public partial class z_test2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lblName.Text = Request.QueryString["UserName"];
            lblEmail.Text = Request.QueryString["EmailId"];
        }
    }
}

Now Run the z-test.aspx and eneter "Mark" in name textbox and mark@gmail.com in email textbox After click on button on "go to Another Page" new window will open with output.

Example 2
z-test.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="z-test.aspx.cs" Inherits="AspDotNets.z_test" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        Name:<asp:TextBox ID="txtName" runat="server"></asp:TextBox><br />
        Email:<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox><br />
        <asp:Button ID="btnSubmit" runat="server" Text="Window Open using Asp.NEt Button" OnClick="btnSubmit_Click"/><br />
       </form>
</body>
</html>

z-test.aspx.cs
using System;
namespace AspDotNets
{
    public partial class z_test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string StrJavaScript = "";
            Response.Write(StrJavaScript);
        }
    }
}

z-test2.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="z-test2.aspx.cs" Inherits="AspDotNets.z_test2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
     Name:-<asp:Label ID="lblName" runat="server"></asp:Label><br />
     EmailId:-<asp:Label ID="lblEmail" runat="server"></asp:Label><br />

    </form>
</body>
</html>
using System;

namespace AspDotNets
{
    public partial class z_test2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lblName.Text = Request.QueryString["UserName"];
            lblEmail.Text = Request.QueryString["EmailId"];
        }
    }
}


Instead of delete trigger in sql server

INSTEAD OF INSERT Trigger


To Create INSTEAD OF DELETE Triggers first of all we need to create a table (but we create two table) for which we apply trigger and we need another table that hold all activity in main table.

--We create tblDeparment table

create table tblDeparment(
Id int identity(1,1) primary key not null,
DeparmentName varchar(30) not null,
Location Char(8) not null,
DeparmentHead varchar(20) not null
)

--Now insert data into tblDeparment 

Insert into tblDeparment values('IT','London','Carrie')
Insert into tblDeparment values('HR','Mexico','Toy')
Insert into tblDeparment values('Purchasing','Delhi','Ravi')
Insert into tblDeparment values('Finance','New York','Janie')

--We create tblEmployee table

create table tblEmployee(
Id int identity(1,1) primary key not null,
Name varchar(30) not null,
Gender Char(8) not null,
DeparmentId int null constraint FK_tblEmployee_DeparmentId foreign key(DeparmentId) references tblDeparment(Id)
)

--Now insert data into tblEmployee 

insert into tblEmployee values('Jane', 'Female', 1) 
insert into tblEmployee values('Levis', 'Male', 3)
insert into tblEmployee values('Lee', 'Female', Null)
insert into tblEmployee values('Rose', 'Female', 1)

Here we create two table “tblDeparment” and “tblEmployee“ which are inter-connected through Foreign key constraint.
We will apply trigger for these tables.

Example 1 Now create table that hold activity of main table by user.
create table tblAudit
(
Id int primary key identity(1,1) not null,
AuditData nvarchar(500)
) 
We have table are given below with data.
all-tables-for-instead-of-delete-trigger
All table are given

Now create the INSTEAD OF DELETE Trigger for “tblEmployee”.
create trigger trtblEmployeeInsteadOfDelete
on tblEmployee
INSTEAD OF DELETE
AS
  BEGIN
     Declare @EmpId int,               
             @EmpMessage varchar(200);
     select  @EmpId =D.Id 
             from deleted D
      
     If(Not exists(Select Id from tblEmployee where Id = @EmpId))   --If Id not Exists in Cloumn than through message. you can check other condition like departmentId =1 or Gender=Male, than you can print message you can not delete
       Begin
           SET @EmpMessage  = 'Employee With Id ' + CAST(@EmpId as varchar(5)) + 'Not Exists in the DataBase'
           Raiserror(@EmpMessage, 16, 1)
           Print 'Employee Not Exists'
           RollBack
       End
       Else
          Begin
             delete from tblEmployee where Id= @EmpId     --delete command      
             insert into tblAudit values('Employee succefully Delete with Id ' + CAST(@EmpId as varchar(5)) + 'and insert into trigger in date' + CAST(Getdate() AS nvarchar(30)))
          End
  END
Now try to delete data from tblEmployee.
If we try to delete id which is not exists than return message Employee with Id not exits delete from tblEmployee where Id=5.
try-to-delete-row-from-table-when-instead-of-insert-trigger
Try to delete from table

Now we try to delete id which is already exists return message succefully row effect delete from tblEmployee where Id=4.
delete-row-from-table
Try to delete from table

Now check data from tables.
select-table-after-fire-instead-of-insert-trigger
Selete table after fire instead of delete trigger

Example 2

For more understand about INSTEAD OF DELETE Trigger we take another trigger example.

First we create another table that hold all activity of main table done by user.
create table tblAuditDetailsBy
(
  Id int not null Primary key identity(1,1),
  EmpId int Not Null,
  EmpName varchar(30) Not Null,
  EmpGender char(8) Not Null,
  EmpDeparmentId int Not Null,
  AuditAction varchar(1000) Not Null,
  ActionTakenBy varchar(50) Not Null,
  AuditTime datetime not null default Getdate(),
  ServerName varchar(100) Not Null,
  ServerInstanceName varchar(100) Not Null
)
Now create the INSTEAD OF DELETE Trigger for “tblEmployee”.
create trigger trtblEmployeeInsteadOfDeleteByDetail
ON tblEmployee
INSTEAD OF DELETE
As
 BEGIN
     Declare @EmpId int, @EmpName varchar(30), 
             @EmpGender varchar(8), @EmpDepatmentId int,
             @EmpMessage varchar(300),@AuditAction varchar(2000),
             @ActionTakenBy varchar(100),@AuditTime varchar(50),
             @ServerName varchar(100), @ServerInstanceName Varchar(100);
             
     select  @EmpId=D.Id, @EmpName = D.Name, --delete not only keep id column value, keep all column value for which id we want delete. 
             @EmpGender= D.Gender, @EmpDepatmentId= D.DeparmentId
             from deleted D
      
     If not exists (Select Id from tblEmployee where Id = @EmpId)   --If Id not Exists in Cloumn than through message, you can check other condition like departmentId =1 or Gender=Male, than you can print message you can not delete
       Begin
           SET @EmpMessage  = 'Employee With Id ' + CAST(@EmpId as varchar(5)) + 'Not Exists in the DataBase.'
           Raiserror(@EmpMessage, 16, 1)
           Print 'INSTEAD OF DELETED Triggers in SQL Server not fire because ' + @EmpMessage
           RollBack
       End
       Else
          Begin
             delete from tblEmployee where Id= @EmpId --delete command                             
             
             SET @AuditAction='Delete Record'
             SET @ActionTakenBy= SYSTEM_USER
             SET @ServerName = CAST(SERVERPROPERTY('ServerName') as varchar(100))
             SET @ServerInstanceName = CAST(SERVERPROPERTY('MachineName') as varchar)
             insert into tblAuditDetailsBy(EmpId, EmpName, EmpGender, EmpDeparmentId, AuditAction,
                                           ActionTakenBy, AuditTime, ServerName, ServerInstanceName)
                                    values(@EmpId,@EmpName, @EmpGender, @EmpDepatmentId, @AuditAction,
                                           @ActionTakenBy, GETDATE(), @ServerName, @ServerInstanceName)
             PRINT 'Successfully Delete Data with ID= ' + CAST(@EmpId as varchar(5)) + CAST(Getdate() AS nvarchar(30));
             PRINT 'Fired the INSTEAD OF Delete Triggers in SQL Server'
          End
 END
Now try to delete data from tblEmployee.
If we try to delete id which is not exists than return message Employee with Id not exits delete from tblEmployee where Id=5.
And if try to delete id which is already exists return message successfully row effect
delete from tblEmployee where Id=2
Delete-data-from-table-than-Instead-of-delete-trigger-fire
Delete data from table than Instead of delete trigger fire
 Now check data from tables.

query string in asp.net


QueryString


When we need to pass variables content from one aspx or html page to another page through URL we use QueryString.
There several choice to pass variables from one page to another but in this session we use QueryString.

QueryString use to display different data on the same page.

Syntax of QueryString

Request.QueryString(variable)[(index).count].

e.g. http://localhost:50419/z-test2.aspx?UserName=Mark&EmailId=Mark@gmail.com  
get-QueryString-in-url
Note:-
1. QueryString consist of two parts (field and value), and each of pair separated by ampersand (&) or semicolon(‘;’). i.e & or ; is used between variables.
2. ? (QuestionMark) sign, indicates the start of a QueryString and & indicate start of another QueryString.

Example
First we create new website "AspDotNets" (you can keep any name) and add "z-test.aspx" webform in website and then write the following code in source mode (look at bottom in webform three mode show design, split and source).
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="z-test.aspx.cs" Inherits="AspDotNets.z_test" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        Name:<asp:TextBox ID="txtName" runat="server"></asp:TextBox><br />
        Email:<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox><br />
        <asp:Button ID="btnSubmit" runat="server" Text="go to Another Page" OnClick="btnSubmit_Click"/><br />
       </form>
</body>
</html>

Now double click on button in design mode and paste the following code in code behind of z-test.aspx i.e. in z-test.aspx.cs
using System;
namespace AspDotNets
{
    public partial class z_test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {  }
        protected void btnSubmit_Click(object sender, EventArgs e)        //carefully copy paste the code because "btnSubmit_Click" should must match with onclick event of button in aspx page i.e. OnClick="btnSubmit_Click" 
        {
          Response.Redirect("~/z-test2.aspx?UserName=" + txtName.Text + "&EmailId=" + txtEmail.Text);
        }
    }
}
Now For receiving the value from the z-test.aspx, we add “z-test2.aspx” webform.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="z-test2.aspx.cs" Inherits="AspDotNets.z_test2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
     Name:-<asp:Label ID="lblName" runat="server"></asp:Label><br />
     EmailId:-<asp:Label ID="lblEmail" runat="server"></asp:Label><br />
    </form>
</body>
</html>
Now write the following code in behind (go to code behind by right click on aspx then select View Code).
using System;
namespace AspDotNets
{
    public partial class z_test2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lblName.Text = Request.QueryString["UserName"];  // We can also retrieve value using their position so we can write code like Request.QueryString[0] also
            lblEmail.Text = Request.QueryString["EmailId"];  // Request.QueryString[1]  
        }
    }
}
Now run the “z-test.aspx” by right click view in browser. Now, enter "Mark" in name textbox and mark@gmail.com in email textbox.
Enter-data-in-textboxes
Enter Value in textbox
After click on button on "go to Another Page"
transfer-deatil-from-one-page-to-another-in-asp.net-using-query-string
Show transfer data from one page to another using QueryString through url

Note:-
If we enter "Mark & Tony" in Name textbox and Email textbox "mark@gmail.com" than outPut Will be like Name:-Mark and Email:- mark@gmail.com.
transfer-deatil-from-one-page-to-another-in-asp.net-using-query-string
Transfer data from one page to another using QueryString through url

After click on button
Show transfer data from one page to another using QueryString through url
Show transfer data from one page to another using QueryString through url

If we use code like below.
lblName.Text = Request.QueryString[0];
lblEmail.Text = Request.QueryString[1];
0 receive first QueryString and 1 receive second QueryString and as we know QueryString separate by & sign.
If retrieve value using their position and we enter we enter "Mark" in Name textbox and in Email textbox enter "mark@gmail.com" than outPut Will be like Name:-Mark Emial:-mark@gmail.com.
But if we enter "Mark & Tony" in name textbox and mark@gmail.com in Email textbox than outPut Will be like Name:-Mark, Emial:-Tony because & use as separator for second QueryString. see in example below.

Example

code at z_test.aspx.cs
code at z_test.aspx.cs
using System;
namespace AspDotNets
{
    public partial class z_test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        { }
        protected void btnSubmit_Click(object sender, EventArgs e) 
        {
          Response.Redirect("~/z-test2.aspx?UserName=" + txtName.Text + "&EmailId=" + txtEmail.Text);
        }
    }
}
code at z_test2.aspx.cs
using System;
namespace AspDotNets
{
    public partial class z_test2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lblName.Text = Request.QueryString[0];  
            lblEmail.Text = Request.QueryString[1];
        }
    }
}
Now run program, and enter "Mark & Tony" in Name textbox and click on button.
transfer-deatil-from-one-page-to-another-in-asp.net-using-query-string
Show transfer data from one page to another using QueryString through url

use & as value in QueryString

If we want to use & as value in name, not as separator for second QueryString, we can achieve this by two way.
1. using UrlEncode
2. By Repalce & and space

Example
1. using UrlEncode

code at z_test.aspx.cs
using System;
namespace AspDotNets
{
    public partial class z_test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        { }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/z-test2.aspx?UserName=" + Server.UrlEncode(txtName.Text) + "&EmailId=" + Server.UrlEncode 
(txtEmail.Text));   //UrlEncode Encode the value which is in the url.
        }
    }
}
code at z_test2.aspx.cs
using System;
namespace AspDotNets
{
    public partial class z_test2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lblName.Text = Request.QueryString[0];    //or   lblName.Text = Request.QueryString["UserName"]; 
            lblEmail.Text = Request.QueryString[1];   //or   lblEmail.Text = Request.QueryString["EmailId"];
        }
    }
}

Now run the programe and Enter Mark & Tony in Name textbox and enter mark@gmail.com in EmailId textbox and click on button.
transfer-deatil-from-one-page-to-another-in-asp.net-using-query-string
Transfer data from one page to another using QueryString through url
transfer-deatil-from-one-page-to-another-in-asp.net-using-query-string
Show transfer data from one page to another using QueryString through url

2. By Repalce & and space

z_test.aspx.cs
using System;
namespace AspDotNets
{
    public partial class z_test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        { }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/z-test2.aspx?UserName=" + txtName.Text.Replace("&","%26") + "&EmailId=" + txtEmail.Text.Replace 
("&","%26")); 
        }
    }
}
code at z_test2.aspx.cs
using System;
namespace AspDotNets
{
    public partial class z_test2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lblName.Text = Request.QueryString[0];    //or   lblName.Text = Request.QueryString["UserName"];
            lblEmail.Text = Request.QueryString[1];   //or   lblEmail.Text = Request.QueryString["EmailId"];
        }
    }
}
Now run the program and enter "Mark & Tony" in name textbox and enter mark@gmail.com in email and click on button.
transfer-deatil-from-one-page-to-another-in-asp.net-using-query-string
Show transfer data from one page to another using QueryString through url

Note:-
In URL space is replace by %20 and & is replace by %26.