Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old September 5th, 2007, 01:44 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Also what is CWebPage? I assume this is a custom class you have overridding some functionality of the System.Web.UI.Page class?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Professional Search Engine Optimization with ASP.NET

Professional IIS 7 and ASP.NET Integrated Programming

================================================== =========
Reply With Quote
  #12 (permalink)  
Old September 5th, 2007, 01:47 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Actually, "An error has occurred" generic error is not typical of .NET you should at least be getting the StackTrace?? In your web.config do you have this attribute: <customErrors mode="Off"/> ??

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Professional Search Engine Optimization with ASP.NET

Professional IIS 7 and ASP.NET Integrated Programming

================================================== =========
Reply With Quote
  #13 (permalink)  
Old September 5th, 2007, 01:48 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
quote:First, no, you can not have t[w]o page load events regardless of where they appear.
That's not true. You can have many Load handlers. Try this:

ASPX
Code:
<%@ Page Language="VB" ... AutoEventWireup="True"
CodeFile="Default.aspx.vb" ....%>
<script type="text/VB" runat="server">
  Protected Sub Page_Load(ByVal sender As Object, _
              ByVal e As System.EventArgs)
    Label1.Text += "From Load ASPX<br />"
  End Sub
</script>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
followed by this code behind:
Code Behind
Code:
Protected Sub Page_Load1(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles Me.Load
  Label1.Text += "From Load 1<br />"
End Sub
Protected Sub Page_Load2(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles Me.Load
  Label1.Text += "From Load 2<br />"
End Sub
Protected Sub Page_Load3(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles Me.Load
  Label1.Text += "From Load 3<br />"
End Sub
If you run this, you'll see that all four methods get fired, albeit in a somewhat unpredictable order.

Now, whether this is a smart thing to do from a maintainability point of view is of course something completely different. I am sure that most people won't like this design.... ;)

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Reply With Quote
  #14 (permalink)  
Old September 5th, 2007, 01:56 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Ahh yes and Imar proves me wrong ;] I guess my rationale for my comment was that it seems unnecssary to have more than one method handle the same event, I can't think of a good reason to justify that sort of design.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Professional Search Engine Optimization with ASP.NET

Professional IIS 7 and ASP.NET Integrated Programming

================================================== =========
Reply With Quote
  #15 (permalink)  
Old September 5th, 2007, 02:02 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

I couldn't agree more. One handler for one event is usually more than enough. More handlers just make your code so much harder to read and understand. Additionally, since you can't really predict order and behavior, you may end up with subtle bugs....

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Reply With Quote
  #16 (permalink)  
Old September 5th, 2007, 02:04 PM
Authorized User
 
Join Date: Sep 2007
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

dparsons-

Yes, CWebPage is a massive beast of a class that modifies System.Web.UI.Page

In my web.config, customErrors was set to On, but there was a page redirect attribute. Taking that out revealed that the actual error I am receiving is this:

The following error has occurred:

Class CustSignIn Error=Object reference not set to an instance of an object.


Although as far as I can tell, everything is declared explicitly now.

I think I'll give Imar's suggestion a try and see what happens...

Reply With Quote
  #17 (permalink)  
Old September 5th, 2007, 02:08 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

If by "giv[ing] Imar's suggestion a try and see what happens..." you mean implementing two Page_Load handlers, you misunderstood me. I am not recommending to do that at all. I only showed that it was possible, not that it's a good or clean solution.

If you have the need for this, you may have other problems that you may need to fix instead....

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Reply With Quote
  #18 (permalink)  
Old September 5th, 2007, 02:08 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

mmm.. make one more try.. surround your database code with a try catch to see if the error comes from there..
Maybe you are not opening the database or something like this???

if you comment that code the page works ok??

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
Reply With Quote
  #19 (permalink)  
Old September 5th, 2007, 02:34 PM
Authorized User
 
Join Date: Sep 2007
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for at least trying to help me, by the way. It is very much appreciated.

Yes, if I comment out those lines in the Codebehind and reinsert this little block back into the aspx file, it works perfectly:
Code:
<script type="text/vb" runat="server">

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim dbconn As New SqlConnection( "server=server.net;uid=username;pwd=password;database=test_storefrontdb" )        
        dbconn.Open()
        Dim dbcomm As New SqlCommand( "SELECT * FROM Products", dbconn )
        Dim dbread As SqlDataReader = dbcomm.ExecuteReader()
        FeaturedItems.DataSource = dbread
        FeaturedItems.DataBind()
        dbread.Close()
        dbconn.Close()

    End Sub

</script>
The unfortunate problem with that is that then the login function which runs from the Runbehind's Page_Load() doesn't work anymore. I really only want to do two things on the page: Provide login functionality and pull up a list of items from a database. If I put the same block of code in the Codebehind, for some reason it just doesn't want to work. Am I missing something obvious? I didn't foresee this being such a complicated thing.

Thanks,

blu

Reply With Quote
  #20 (permalink)  
Old September 5th, 2007, 02:38 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

can you try put it back in the code behind file and surround it with a try catch to see which error did it throw??

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
simple report and crystal report in vb.net saket123 .NET Framework 2.0 0 August 13th, 2008 06:55 AM
Indian Rs Format simple Function for vb.net s.karthik General .NET 0 March 24th, 2008 06:27 AM
MSSQL 2005 and MSSQL 2000 tiredcat Visual Basic 2005 Basics 0 April 9th, 2007 12:56 AM
Simple ASP.NET message box with VB janicen General .NET 1 February 24th, 2005 03:31 AM
VB MSSQL database REmote connectivity srichary Pro VB Databases 0 November 28th, 2004 06:33 AM



All times are GMT -4. The time now is 03:15 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.