Hi Folks,
I have set the custom error page so that when ever some error generate then the user will be redirected to a custom error page. But my problem is that system is not showing the custom error page despite experiencing errors.
Here is the code
web.config file
===================================
<customErrors mode="On" defaultRedirect="error.aspx">
<error statusCode="500" redirect="error.aspx"/>
<error statusCode="400" redirect="error.aspx"/>
</customErrors>
===================================
General function
===================================
public DataSet GenerateDataset(string query)
{
if (conn.State == ConnectionState.Open)
conn.Close();
conn.Open();
try
{
adap = new OdbcDataAdapter(query, conn);
ds = new DataSet();
ds.Clear();
adap.Fill(ds);
return ds;
}
catch (Exception ex)
{
throw ex;
}
finally
{
adap.Dispose();
conn.Close();
}
}
=======================================
Main Portion
=======================================
objGen = new GeneralFunction();
ds = new DataSet();
try
{
ds = objGen.GenerateDataset(strQuery);
if (ds.Tables[0].Rows.Count > 0)
{
GridView1.DataSourceID = null;
GridView1.DataSource = ds;
GridView1.DataBind();
Lbl_rc.ForeColor = System.Drawing.Color.Black;
Lbl_rc.Font.Bold = true;
Lbl_rc.Text = "<font color='#009933'>Total no of unconfirm orders : " + ds.Tables[0].Rows.Count + "</font>";
trP1.Visible = true;
GridView1.Visible = true;
}
else
{
GridView1.DataSourceID = null;
Lbl_rc.ForeColor = System.Drawing.Color.Black;
Lbl_rc.Font.Bold = true;
Lbl_rc.Text = "<font color='#FF0000'>No unconfirm orders in the list.</font>";
trP1.Visible = false;
GridView1.Visible = false;
}
}
catch(Exception ex)
{
Tabok.Visible = false;
tab3.Visible = true;
lblmsg.Visible = true;
lblmsg.Text = "Error : " + ex.Message;
}
finally
{
strQuery = "";
ds.Dispose();
objGen = null;
}
Please let me know what is wrong with above code