Yes, we can do this, but to handle errors, we must know the
error
codes; only then we can take the user to a proper error
message page,
CustomErrors Configuration section in web.config file:
The default configuration is:
< customErrors mode="RemoteOnly"
defaultRedirect="Customerror.aspx" >
< error statusCode="404"
redirect="Notfound.aspx" / >
< /customErrors >
If mode is set to Off, custom error messages will be
disabled. Users
will receive detailed exception error messages.
If mode is set to On, custom error messages will be enabled.
If mode is set to RemoteOnly, then users will receive custom
errors,
but users accessing the site locally will receive detailed
error
messages.
Add an < error tag for each error you want to handle. The
error tag
will redirect the user to the Notfound.aspx page when the
site returns
the 404 (Page not found) error.
[Example]
There is a page MainForm.aspx
Private Sub Page_Load(ByVal sender As System.Object, ByVal e
As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim str As System.Text.StringBuilder
str.Append("hi") ' Error Line as str is not
instantiated
Response.Write(str.ToString)
End Sub
[Web.Config]
< customErrors mode="On"
defaultRedirect="Error.aspx"/ >
' a simple redirect will take the user to Error.aspx [user
defined]
error file.
< customErrors mode="RemoteOnly"
defaultRedirect="Customerror.aspx" >
< error statusCode="404"
redirect="Notfound.aspx" / >
< /customErrors >
'This will take the user to NotFound.aspx defined in IIS.
· How do you implement Paging in .Net?
The DataGrid provides the means to display a group of
records from the
data source (for example, the first 10), and then navigate
to the
"page" containing the next 10 records, and so on
through the data.
Using Ado.Net we can explicit control over the number of
records
returned from the data source, as well as how much data is
to be cached
locally in the DataSet.
1.Using DataAdapter.fill method give the value of
'Maxrecords'
parameter
(Note: - Don't use it because query will return all records
but fill
the dataset based on value of 'maxrecords' parameter).
2.For SQL server database, combines a WHERE clause and a
ORDER BY
clause with TOP predicate.
3.If Data does not change often just cache records locally
in DataSet
and just take some records from the DataSet to display.