Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Mystery of the disappearing page

Author  Topic 

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2006-05-31 : 11:21:57
I have setup a very simple ASP.NET app.

The first page lets the user search for what they want, the second lets them edit the record.

It's the second page that is causing me problems. On their I have a button which is intended to check the data entered (by calling a function I have written) and then update the database.

My problem is this. When they click the button, the page either clears itself (i.e. the objects on it dissappear a few at a time, working from the bottom up) or I get the
quote:
The page cannot be displayed
error.

I've tried setting breakpoints in the page load event and the button click event but it never gets there.

Does anyone know how to start to work out what is going on here?

many thanks in advance

steve

-----------

Oh, so they have internet on computers now!

JBelthoff
Posting Yak Master

173 Posts

Posted - 2006-05-31 : 19:51:32
If you set the ASP Trace on you can follow and see where in the process the paged stopped. This is useful sometimes.

You can do it in the page or in the web.config file.

In Web.config
<trace enabled="true" requestLimit="150" pageOutput="true" traceMode="SortByTime" localOnly="false" />


In the page
<%@ Page Language="vb" trace="True" ... %>


Don't forget to shut it back off when you're done!




JBelthoff
• Hosts Station is a Professional Asp Hosting Provider
• Position SEO can provide your company with SEO Services at an affordable price
› As far as myself... I do this for fun!
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2006-06-01 : 03:21:09
Thanks for the tip. I should have mentioned I had tried tracing the page but it hadn't given me any useful information. Perhaps it's just one of those things that will suddenly start working as expected

steve

-----------

Oh, so they have internet on computers now!
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2006-06-02 : 05:45:16
This is starting to freak me out now. I thought about this a lot and figured that the page load event needed a rewrite which I have done.

The page still works on the first load as it did before.

However, the button is still causing problems. I still get the same issue, i.e. either a completely blank page or a page not found error.

I tried changing the code for the button click event to

Response.Redirect("www.sqlteam.com")

.and it seems to be ignored, I still get the same error as above, so I guessed that it was doing a postback before calling the button code but that doesn't seem to be happening either because the page is showing blank (no trace data at the bottom) AND I put in some javascript to tell me if a postback occured or not and this doesn't fire apart from on the first page load.

The page has some dropdowns populated from quite large tables in my database. Could this be having an effect?


-----------

Oh, so they have internet on computers now!
Go to Top of Page

JBelthoff
Posting Yak Master

173 Posts

Posted - 2006-06-02 : 07:41:59
quote:
Originally posted by elwoos
The page has some dropdowns populated from quite large tables in my database. Could this be having an effect?


Nope that wouldn't have anything to do with it. It sound like your button_click is not wired up correcly.

Are you doing this code by Hand or using Visual Studios? Could you post the ASP code for the button on the asp page and also the button_click sub code so we could take a look.



JBelthoff
• Hosts Station is a Professional Asp Hosting Provider
• Position SEO can provide your company with SEO Services at an affordable price
› As far as myself... I do this for fun!
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2006-06-02 : 08:20:32
Hi JBelthoff thanks for responding. I wondered if it was that so I tried changing the code in the button click event to response.redirect("www.sqlteam.com") and still it didn't fire.

I'm using VS 2003 and when I double click on the button in that it takes me to the event code that I expect -
 Private Sub butUpsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butUpsert.Click
' TODO: may need validation routines here instead of where they are
' Trace.Warn("upsert button clicked")
Response.Redirect("www.sqlteam.com")
' SubmitData()
End Sub


the HTML for the button is

<asp:Button id="butUpsert" runat="server" Text="Upsert"></asp:Button>


The "best" I get is a completely blank page this is ALL of the HTML of it

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>


I think my real problem is that I have hit a brick wall with regard to debugging this - I don't know what else I can try. I have setup a trace, breakpoints, putting javascript messages to the client etc.

Many thanks


steve

-----------

Oh, so they have internet on computers now!
Go to Top of Page

JBelthoff
Posting Yak Master

173 Posts

Posted - 2006-06-02 : 09:40:40
Try adding http:// and let me know what happens. Because I don't think you have a page named "www.sqlteam.com" on your website so you would get a page not found.

Private Sub butUpsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butUpsert.Click
' TODO: may need validation routines here instead of where they are
' Trace.Warn("upsert button clicked")
Response.Redirect("http://www.sqlteam.com")
' SubmitData()
End Sub


JBelthoff
• Hosts Station is a Professional Asp Hosting Provider
• Position SEO can provide your company with SEO Services at an affordable price
› As far as myself... I do this for fun!
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2006-06-02 : 10:08:08
Sorry to say that the HTTP:// made no difference whatsoever.

When the blank page comes up, the address bar still has the same name on it as the page with the button. I have some other hidden buttons (that aren't used) on that page. Could it possibly be connected to them?

Apart from that the HTML on the page is pretty standard, a few labels, text boxes, drop downs and check boxes. There is also a page header which is a Web User Control but that seems to work fine elsewhere that it is used

steve

steve

-----------

Oh, so they have internet on computers now!
Go to Top of Page

JBelthoff
Posting Yak Master

173 Posts

Posted - 2006-06-02 : 10:29:18
OK we now know that your button click is not wired up correctly. Now what we have to do is find out why...

Could you email me your code. I think posting the pages here would be a little much.

I have an idea what it is, but would like to see the whole thing.





JBelthoff
• Hosts Station is a Professional Asp Hosting Provider
• Position SEO can provide your company with SEO Services at an affordable price
› As far as myself... I do this for fun!
Go to Top of Page

JBelthoff
Posting Yak Master

173 Posts

Posted - 2006-06-02 : 11:32:19
I think I got it...

Does this look familiar?

Object reference not set to an instance of an object.

Change this:

If IsPostBack Then ' i.e. a postback has occurred
Trace.Warn("Postback occured")
Dim m As New String("Postback occurred - page loading")
ASPNET_MsgBox(m)
' do non initialisation
' show any errors that exist
If des.Count > 0 Then
lblErrors.Visible = True
Trace.Warn("show errors")
End If


To this

If IsPostBack Then ' i.e. a postback has occurred
Trace.Warn("Postback occured")
Dim m As New String("Postback occurred - page loading")
ASPNET_MsgBox(m)
' do non initialisation
' show any errors that exist
'If des.Count > 0 Then
'lblErrors.Visible = True
'Trace.Warn("show errors")
'End If



And tell me what happens. I think it will work for you now. At least the redirect and the button_click sub.

Here is what you did.

You declared: Private des As ErrorDetails ' collection of data errros
In the page load you did this: des = New ErrorDetails

But in the post back there is no des. To carry this over between page post backs, you should do this;


Protected Withevents des as system.whateveritis


Or you would need to do this in the page load:
ViewState("des") = des

And then change If des.Count > 0 Then to If ViewState("des").Count > 0 in the post back.

You are not passing this object between post backs but are trying to read from it on the post back when it is not there.

Let me know if it works for you.




JBelthoff
• Hosts Station is a Professional Asp Hosting Provider
• Position SEO can provide your company with SEO Services at an affordable price
› As far as myself... I do this for fun!
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2006-06-05 : 04:29:27
Hi

Many thanks for taking the time to look at this for me.

I'm afraid I still get the same. I understand what you are saying about my des object and have tried a few other variations to no avail.

I think I have decided to cut my losses and recreate the page from scratch. This could remain one of the great mysteries of life

many thanks

steve

-----------

Oh, so they have internet on computers now!
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2006-06-05 : 05:50:11
A CLUE - finally I have a clue

It's something to do with the drop downs that I have on the page.

The page has 5 drop downs populated from tables with from 1,500 to over 70,000 records. On my shiny "new" page I've used the same code to populate the drop down boxes and put in the page load event
        If Not Page.IsPostBack Then
PopulateDropDowns() ' gets the database data into the drop downs
End If


as soon as I did that I got the same as with the original page. If I comment out the middle line it all works as expected.

I suppose that this leaves me with a dilemna as I'm not sure what my options are. Cumbersome though it is I would like to have these dropdowns fully populated (data entry would still be quicker than the alternative). The only other option I could think of would be to redesign the user interface to give some sort of search facility to get the values that would go in these drop downs. Does anyone have any other ideas? I did wonder about a populate on demand drop down component but haven't found one.

thanks

steve



-----------

Oh, so they have internet on computers now!
Go to Top of Page

JBelthoff
Posting Yak Master

173 Posts

Posted - 2006-06-05 : 09:56:19
70,000 records is a lot to put into a drop down. I could not test that because I did not have your DB so I commented it out. But your post back was giving a problem because of the des.

Anyway... here is some general advice.

1. Lose all of your error display code. It's not needed. Asp.Net will handle the errors and give you an error page. And the debugger will help also. You have a lot in there to display errors using javascript and you don't need them.

2. Program your page 1 step at a time and verify each step along the way. When you have one step working ONLY then move on to the next part.

3. Don't put all of your data binding in to one procedure. If you have multiple drop downs that need to be populated or databound, do them one at a time. Allow for each one to have an error handler so you know where the error came from and what to do if it happens again. You can do this using functions instead of sub procedures.

At this point I would start over from scratch. Clean up your code and keep it simple. That is the only way you are ever going to know what is happening.

And always make sure you are passing your objects to the post back.

I wish I could have been more help.



JBelthoff
• Hosts Station is a Professional Asp Hosting Provider
• Position SEO can provide your company with SEO Services at an affordable price
› As far as myself... I do this for fun!
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2006-06-05 : 11:55:20
You've been very helpful, thanks very much.

To be honest the javascript was only to try to work out where the problem was coming from. I have decided to rewrite the page from scratch as you suggest as it was getting very messy even by my standards. I've also redesigned the user interface so that I don't need the largest drop downs anymore - it will take the user longer to enter the data overall but the application does appear to them to be much faster.

I suppose this is an "easy trick" that will keep users happy.

Thanks again for your help and advice they are all much appreciated

steve

-----------

Oh, so they have internet on computers now!
Go to Top of Page
   

- Advertisement -