I have an intranet application which is composed of a listbox which, when the user double-clicks an item, sets an iFrame's source to the associated aspx page using javascript (the name of the page is the value of the listbox). Like this:
function GetLetterForm()
{
$find('ModalPopupExtender1').show();
$("#ltrVariables").attr('src', $("#lstNames").val() + ".aspx"); //these two lines are interchangeable
//document.ltrVariables.location = document.getElementById("<%= lstNames.clientID %>").value + ".aspx";
$find('ModalPopupExtender1').hide();
}
It works, but I still have one issue. Occasionally, there is a value in the listbox that has no associated webpage. For example, selection "Bob" has a value of 438, but I don't have a 438.aspx webpage.
So I get a "Server Error - resource could not be found" in my iFrame. Not pretty.
What I'd like to do is to (somehow) hook the error, and display a general "Sorry, the dog ate my homework" aspx page when this happens.
But I have no idea how to accomplish this.
Any ideas would be greatly appreciated.
Thanks,
Jason
EDIT: I really don't want to use IIS handling of this, as I have a separate error webpage for my master pages. Thanks!
Perhaps the following link might work. It is about custom 404 pages.