We are having a very large project in asp.net 3.5. During code review of project we have found that page_load event of one control is firing twice in the firefox browser. After doing some debugging i have found that it's due to one of the link button which is there in the control. I like to share you the same scenario with you all guys.
One of the developer from us has specified the link button click event two times. The first one in directly in the html with onclick like following.
- <form id="form1" runat="server">
- <div>
- <asp:LinkButton ID="lnkButton" runat="server" onclick="lnkButton_Click"></asp:LinkButton>
- </div>
- </form>
And another in the initialize event he has also attached the event handler for the click event like following.
- protected override void OnInit(EventArgs e)
- {
- lnkButton.Click += new EventHandler(lnkButton_Click);
- base.OnInit(e);
- }
So i have removed one of them from initialize event and now its calling page_load event only one time. This is also responsible for the failed to load ViewState error some time when you are adding controls dynamically.
Happy programming...
there are other things in aspx that also causes to fire page_load twice in firefox only.
ReplyDeleteplease refer this article for more details
http://patelshailesh.com/index.php/page_load-event-fires-twice-with-firefox-only
Thanks Shailesh for giving us details.
ReplyDelete