ASP.Net GridView Paging and Configuration
ASP.Net GridView Paging and Configuration
Net
Right Click -> Properties -> Allow Paging (true) ->Page Size(enter preferred
pages) -> Go to Event -> Page Index Changing (handle this event) ->
Repeater Control
Repeater is a unstructured control. We have design it's column by our requirement.
DataList
This control is used to display back-end data in front-end like GridView.
The Speciality of this control is that it display the data in the form of columns.
It is not able to show data itself if we want to show data we have to design it's column.
20/02/2024 Configuration Support in [Link]
Note- In HTML there are predefined tags while in XML we can define our own tags. XML file is not compile direct run
<appsettings>
<add key="ri" value="18.24"/>
</appsettings>
----C# file----
using [Link]
[Link]=[Link]["ri"];
2- <connectionstring> tag - This tag is used to define connection string globaly by which we can call it anywhere in our
project
<connectionstring>
<add name="sqlcn" connectionstring="___________Connection string"/>
</connectionstring>
----C# file----
using [Link]
string c = [Link]["sqlcn"].ConnectionString; (define it globally)
Operating System provides security to their resources by using authentication & authorization. These two
concepts are used in [Link] to implement security.
Authentication
The process of verifieng user credential against specified data source is called as authentication.
Authorization
The process of allocating proper resourcesis performed by authorization.
Authentication has 3 types:
1. Windows Authentication- Used for Intranet Application
2. Passport Authentication
3. Forms Authentication- Used for Internet Application
Windows Authentication:
Client Request to access IIS Server WAT (Windows Authentication Ticket
view secured pages
verify
login DB
Passport Authentication:
Request to access
Verify
IIS server
User View pages by PAT
fir y
ev ot
ytir
Log
in W
oh
ind
tua
ow
Match/authenticate
Third Party
provide PAT(Passport
Authentication Ticket DB
IIS
Server
Request to access
secured pages
DB
namespace Secured_Application
{
public partial class empreg : [Link]
{
protected void Page_Load(object sender, EventArgs e)
{
}
public string CreatePassword(int length)
{
const string valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
StringBuilder res = new StringBuilder();
Random rnd = new Random();
while (0 < length--)
{
[Link](valid[[Link]([Link])]);
}
return [Link]();
}
}
}
}
How to fetch Image from Database / server in [Link]
_______________________________
With the help of cookies We can generate Ticket to access secured pages by verifying identity.
To generate cookies in [Link] we use HttpCookie class which is present in System namespace.
Persistance cookies: It is stored in browser till its set timing. When the timing end it will be destroyed.
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace Secured_Application
{
public partial class Login_Page : [Link]
{
string c = [Link]["sqlcn"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
Secured page code
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace Secured_Application.Userhomepage
{
public partial class WebForm1 : [Link]
{
protected void Page_Load(object sender, EventArgs e)
{
if ([Link]["mycookie"]!=null)
{
[Link] = [Link]["mycookie"].Value;
}
else
{
[Link]("~/[Link]");
}
}
}
}
01/03/2024
How to Destroy cookies in [Link]
DrawBack Of cookies
1- Less Secure
2- It uses client storage
3- Large amount of data we can not store in Cookies
Session in [Link]
1--
protected void Button1_Click(object sender, EventArgs e)
{
if(.............)
Session["mycookie"]=[Link];
[Link]("~/user/user_home.aspx");
}
2--
if(Session["mycookie"]!=null)
{
[Link]=Session["mycookie"].ToString
}
namespace Secured_Application.Userhomepage
{
public partial class Userhome : [Link]
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["mycookie"] != null)
{
[Link] = Session["mycookie"].ToString();
[Link] = 1; //minutes.. 20 min
}
else
{
[Link]("~/[Link]");
}
}
}
}
namespace Secured_Application
{
public partial class Login : [Link]
{
//string c = [Link]["sqlcn"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
[Link]("~/Userhomepage/[Link]");
}
else
{
[Link]("Invalid User");
}
}
}
}