Hi Nic,
Java or VB Client side scripting is the way to go. I just helped one of my
co-workers do something similar to this. He want to throw up a modal dialog
box if there was an exception on the server side. The tricky part is how do
you get from doing something in the business logic on the sever to
displaying something in script on the client side.Here is what we did to
solve our exception problem which you can adapt to fit your needs:
First we created a session variable in the session start event in the Global
asax file called LastError. we set the LastError to some text string. Then
in all the try catch blocks, we added code to put the exception in the
LastError session variable. We made a generic Page called
displayerror.aspx. All it did was read the exception from LastError, and
output it to the screen. After it read the exception it reset the LastError
to a text string. Next in the html of every page we had a simple java
script function to open a modal dialog window that pointed to our
displayerror.aspx page. The script was just a function called ShowError().
So now the ShowError() function is in every html page but never runs. The
way we made it run is adding code to every pages on load event. The code
test to see if it can cast the LastError session variable into an exception.
if it can, it sets the Body tags "onload" attribute to call the local
ShowError() function otherwise it sets the attribute to nothing so that no
script is run.
So to get the client side to show an error that happened on the server side
all you do is set the LastError session var to a valid exception and reload
the page. The page load will find that the LastError Session var is an
exception and set the onload attibute to call the ShowError() local
javascript function. The ShowError() function will call the
DisplayError.aspx page which will display the error to end user locally and
reset the value of the LastError session variable back to text. The next
time the page load event fires, it will try to cast LastError to an
exception and fail, which will reset the Body tags "onload" attribute back
to nothing.
I think you can use this model to do what you are trying to do, it worked
well for us.
Nic said:
Hey,
Is it possible to direct me in the right way with following problem :
I have an ASP page with some input and a button.
When I click the button I go to the server and do some business logic.
This business logic results in an OK or a fault.