showing custom error to user

Asked By theiry henry
12-Aug-10 01:37 AM
Earn up to 0 extra points for answering this tough question.

i m gettting error of conflict voilation when i m deleting any record from Datagrid .this err is due to foreign key referenced to other table.I want to catch this err from domain service and show a custom err to user..How can i do dat.plz nyone help me out..

  re: showing custom error to user

Sandra Jain replied to theiry henry
12-Aug-10 03:01 AM
Write a function like this in code behind:

Private Sub ShowMessage(ByVal type As String, ByVal Message As String)
      ScriptManager.RegisterStartupScript(Me, Me.GetType(), type, "<script>alert('" & Message & "');</script>", False)
    End Sub

Now whereever you handle it just call this function and pass your custom message like this:

ShowMessage("error", "Foreign key violated")
Create New Account