473,396 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

CodeBehind But Not Postback - Page_Load fires twice

Hello All,
I am trying a non-standard approace to asp.net that i hope will work so I
can get an xhtml complient page.

Setup as Follows:
Code-behind but not form runat="server" so traditional Request.Form("key")
handling of the POST event. No server-controls (only html elements)
Desire:
Not to have to code-inside.

What's occuring on POST events (and I do not have many forms on my site so
this is a nice-to-have answer)

AutoEventWireup="false"

Page_Load () Handles MyBase.Load
HandleFormPost(Request)
end Sub

Sub(objRequest as HttpRequest)

Do form processing

end sub

Soo.. with that setup info. I put breakpoints in my OnLoad and its running
twice and has the whole form collection on both times around so I can't go..
if request.form("key").Length = 0 or something like that.

Has anyone used the same set-up of not form-runat="server" so you can get
valid xhtml pages? i.e. the viewstate is not-self-closing so it breaks my
validation.
Thanks to all!

Nov 19 '05 #1
4 5717
Hmm,

seems normal to me as Load event fires always once during a request (once
for the initial request and then once per postback).

You could use Page.IsPostBack property to check whether it is a postback or
not and that way run your logic.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

Nov 19 '05 #2

Because I am not using postback and <form runat="server" the IsPostBack
property is always false.

when I mean it runs twice I mean:

_Load method runs once on initial rendering of page.

user fills out form, and clicks html <button or <input type="submit"

codebehind enters _Load which calls a function (inside that function is one
of two redirects depending on a boolean state, one-redirects back to same
page, two-redirects to a second page.

The code goes through, hits the redirect line, but then goes back up into
the same page's _Load, and runs through again. Only on the second time
hitting the redirect code does the page actually go to the redirect location.

It's strange.
Nov 19 '05 #3
Ah, I see.

Can you provide a small snippet which would demonstrate it? It's easier to
repro that way.

Thanks,

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

Nov 19 '05 #4
Teemu,
I appologize, looks like it was my fault. But it was baffling at first
because this was happening when browsing the page in IE only.

what I had done was an onsubmit validator for the form was bound.. but
instead of just returning true in the validator if success, it was calling
form.submit() and therefore, in IE the form appeared to post twice but in
other browsers it posted once. I found this quite odd but have corrected
the JS and it resolved the issue.

Thank you for taking the time to answer my earlier post.
Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jay Douglas | last post by:
Hello all, I have a asp.net page that creates a pdf on the fly and sends the pdf down to the browser. When calling the page up in IE the Page_Load event is fried twice. This doesn't happen with...
0
by: Sparhawk | last post by:
I got a weird problem with a repeater. The Repeater has an ImageButton in its ItemTemplate. The Repeater has an ItemCommand defined. If the user clicks one of the buttons, nothing happens. If...
2
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control...
4
by: Bob P. | last post by:
Hello, I have a page with: * two side-by-side asp:listboxes and two arrow asp:buttons allowing users to add/remove email addresses between them -- very much like Outlook, where you have the...
4
by: Seraph | last post by:
Again, I'm rather new here, so if I fail to follow any etiquette, please forgive me and let me know what I've done wrong, but I think this might interest quite a few people. One of my colleaques...
2
by: COHENMARVIN | last post by:
I have a form with a Submit button. The user fills out the form, clicks the submit button, and then the page posts back to itself. Every time the page posts back to itself, the "Page_Load" event...
1
by: choukrou | last post by:
Hello everybody! Got a nice problem on 1 of my aspx (and only one): It was working "perfectly" for 1year and a half. Last week I had to fix a lil bug. I do that and test my app. And on the fixed...
11
by: antonyliu2002 | last post by:
I know that this has been asked and answered thousands of times. As a matter of fact, I know that I need to say If Not Page.IsPostBack Then 'Do something End If for things that needs to be...
2
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.