Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Counting Views for an ASP.net Page
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Counting Views for an ASP.net Page

 Post Reply Post Reply Page  <123
Author
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 01 November 2004 at 3:59am
You have placed the Response.Write's correctly and from the look of it Page_Load is being called twice and they are both not postbacks, I would rewrite the page, that usually solves things.
Back to Top
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Posted: 01 November 2004 at 2:14pm

Mart,

I found out exactly what was wrong. I wish that I had known about this before. Thank you for the information about response.write because it certainly helped me.

The line of code:  Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load was what caused the sql statement to execute twice. I changed the code to Private Sub Page_Load(). Do you know why the code associated with Sub Page_Load caused the sql statement to be executed twice? I am just curious about why this happened.
                           

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 01 November 2004 at 3:37pm

Oh sorry, I'm stupid, you just needed to tweak the page directive to

<%@ Page language="vb" AutoWireupEvent="false" %>

the problem is that because you are using inline code asp.net will automatically fire Sub Page_Load (which caused the first execution) then asp.net will fire the MyBase.Load event handler (which caused the second execution because you had Handles MyBase.Load). Setting AutoWireupEvent will tell asp.net not to fire MyBase.Load

Back to Top
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Posted: 01 November 2004 at 3:45pm
I got the following error message: The 'AutoWireupEvent' attribute is not supported by the 'page' directive. when I added the above page directive. I thought I'd let you know about this. It worked fine when I just had Sub Page_Load().
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 01 November 2004 at 3:52pm
meant to be AutoEventWireup="false"... I am half asleep tonight
Back to Top
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Posted: 01 November 2004 at 3:56pm

Thanks! It worked.

Back to Top
 Post Reply Post Reply Page  <123

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.