For example, I put a "abc" on a decimal column. Of course there would be the error page. But the thing is that I don't want that to appear. I want a message box to appear saying that "Action is not allowed" or something like it.
How do I do that?
How do I make an "Error Form" in ASP.Net when I purposely make a mistake?
Use a try/catch block and in the catch use a Response.Redirect("yourerrorpage.aspx?Ms... + "your message here.");
EXAMPLE:
try
{
...
}
catch (Exception ex)
{
Response.Redirect(@"generalerror.aspx?... + PageUtils.Clean(ex.Message));
}
/// %26lt;summary%26gt;
/// Removes any embedded newline characters from a string
/// %26lt;/summary%26gt;
/// %26lt;param name="text"%26gt;The string to be cleaned%26lt;/param%26gt;
/// %26lt;returns%26gt;A string without newline characters.%26lt;/returns%26gt;
public static string Clean(string text)
{
string buf = text;
if (text.Length %26gt; 1000)
{
buf = Clean(text.Substring(0, 1000), Constants.CRLF);
}
else
{
buf = Clean(buf, Constants.CRLF);
}
return buf;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment