Click here to Skip to main content
15,899,937 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
VB
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click

        Dim objadd As New School
        Try
            If objadd.SearchSchool(txtemiscode.Text).Rows.Count >= 0 Then

                Response.Redirect("Emis_Sch_View.aspx?EmisCode=" & txtemiscode.Text)
            End If
            MsgBox("School does not Exists")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        
    End Sub
Posted
Comments
Ed Nutting 25-Aug-11 11:00am    
No code can be executed after calling response.redirect except exception handling code and response.redirect can only be called once. You do not have an error here - after calling response.redirect a thread abort exception is thrown to end the current request. Catch it and don't worry about it, just allow the redirect to happen.
[no name] 25-Aug-11 11:01am    
I don't see any string manipulation.
Ed Nutting 25-Aug-11 11:04am    
I think he meant the "Emis_Sch_View.aspx?EmisCode=" & txtemiscode.Text but the error is irrelevant as I just remembered - it is thrown when you call Response.Redirect to end the current request and should be ignored - the page will redirect properly regardless unless a fatal/unhandled exception is thrown or this one isn't caught :P He's debugged an error, not understood it nor researched it and thinks it's a problem - if he just let his code run through he'd see his page redirect as he wishes it too.
[no name] 25-Aug-11 13:03pm    
"He's debugged an error, not understood it nor researched it and thinks it's a problem"
I am humbled to be in the presence of one so all-seeing and all-knowing as you.

I highly doubt you started coding and immediately knew everything and what to do in all cases. Give it a rest. This is where people come to learn.
Ed Nutting 25-Aug-11 13:29pm    
No I didn't know everything, but I researched it till I found the solution and knew what it was and debugged stuff properly to see whether the error actually mattered or not and what it really meant/what caused it. It is rather annoying to find so many thousands of questions being asked either demanding huge amounts of code or entire programs (not in this case) or where the user just hasn't bothered to research the error/problem. I suggest CP also implements a question analyser system to stop repeat/look-a-like questions, but I don't doubt they would say that is much to bigger task etc etc.

People come here to learn, yes, but first they should try using the search box, not the ask question link.

Response.Redirect("Emis_Sch_View.aspx?EmisCode=" & txtemiscode.Text)


This is stopping all further processing, you should have nothing after this. Why are you trying to use MsgBox in an ASP.NET application anyway?
 
Share this answer
 
Comments
zamani2 25-Aug-11 12:32pm    
but it doesnt return anything to the directed page. actualy the message box is for notifying the user that txtemiscode.text doesnt return anything
[no name] 25-Aug-11 12:59pm    
MsgBox is a Windows function and this code is being executed on the server. The user, nor anyone else, will ever see a messagebox. If you want it displayed to the user it must be done on the client-side with JavaScript.
zamani2 25-Aug-11 13:03pm    
owk! tanx and what about the error "thread was being aboarted?"
What is written in the title of this question is not true. No, you did not receive this error message, I'll guarantee that.

—SA
 
Share this answer
 
Comments
Simon Bang Terkildsen 25-Aug-11 23:41pm    
HAhaha
Sergey Alexandrovich Kryukov 25-Aug-11 23:48pm    
I see you agree. :-) Thank you, Simon.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900