70547

YUI Button initiates Postback Twice

Question:

I'm using ASP.NET 2.0 under VS 2005.

Page_Load is getting called twice for my .aspx pages. AutoEventWireup is set to true, but even if I set it to false and manually add the EventHandler, it still gets fired twice.

// also set AutoEventWireup to false public _Default() { this.Load += new EventHander(this.Page_Load); } // oops -- fired twice

In the Default.aspx page, after the user enters their username & password, I do a redirect to another page, but it seems to redirect back to the Default.aspx page.

I don't have any <img> tags without a src. The tags that have a RunAt="server" attribute are <asp:PlaceHolder>.

For everything else, I use YUI CSS and JavaScript. I don't have any <ASP:> controls.

What am I missing?

<h3>Update</h3>

I'm using the Button widget from the YUI library. If you specify "submit" in both Javascript and in the HTML code for a button, then when you submit, that JavaScript event gets generated twice.

This was a pain to figure out: I started commenting out bits and pieces of JavaScript and CSS (especially the includes), until the event fired only once.

Answer1:

A redirect is a postback in ASP.NET. If you trigger an event(enter user name and click, 1 postback), redirect to the same page(2nd postback). Am I understanding you correctly?

Answer2:

Are you by any chance using this.PreviousPage in the redirected Page ?

Answer3:

So I'm using the YUI framework. And I'm using the Button widget. If you specify "submit" in both Javascript and in the HTML code for a button, then when you submit, that Javascript event gets generated twice. Just remove one of the submits.

This was a pain to figure out: just start commenting out bits and pieces of Javascript and CSS (especially the includes), until the event fires only once. That way you can see what is causing the Page_Load to get fired twice.

Recommend

  • How to set which Boost unit test to run
  • How to get the input from a text box on a webpage form
  • I want to bind the click event to the li elements in the xpages type-ahead
  • need to identify dynamic input/textareas when inserting to database
  • How to dynamically generate javascript using ScriptSharp?
  • Apache redirect from root
  • Working example of paypal Website Payments Pro Hosted Solution Iframe?
  • Passing Props from State to Child
  • How to do popup on new site for 301 redirected users?
  • Disable add to cart redirection
  • django server code not updating
  • Build URLS from JSON
  • Installing SSL on AWS EC2 Bitnami Mean Stack
  • Is it safe to accept URL parameters for populating the `url_for` method?
  • Express JS Display Data By ID
  • Ionic storage “get” returns null only on the second call within method
  • Randomizing -and remembering that randomisation- multiple choice questions in php
  • pip in virtualenv gets ConnectTimeoutError
  • Element.tagName for python not working
  • MongoError: Incorrect arguments
  • Django rest serializer Breaks when data exists
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Modifying destination and filename of gulp-svg-sprite
  • Web-crawler for facebook in python
  • Rearranging Cells in UITableView Bug & Saving Changes
  • GridView Sorting works once only
  • Circular dependency while pushing http interceptor
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • Linker errors when using intrinsic function via function pointer
  • A cron job substitute?
  • Codeigniter doesn't let me update entry, because some fields must be unique
  • Getting error when using KSoap library to consume .NET web services
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • need help with bizarre java.net.HttpURLConnection behavior
  • Turn off referential integrity in Derby? is it possible?
  • Authorize attributes not working in MVC 4
  • Busy indicator not showing up in wpf window [duplicate]
  • UserPrincipal.Current returns apppool on IIS
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF