locked
Firefox updatepanel defaultbutton issue RRS feed

  • Question

  • User1225142132 posted

    I have searched all over the forums and have seen simliar issues but there never seems to be a permanent fix.  I am running the June release of the toolkit.

    I am experiencing the following issues:

    I have an asp:Panel insided of an UpdatePanel.  The DefaultButton attribute of the asp:Panel is set to an asp:ImageButton (it is inside the asp:Panel).  I have a ToolkitScriptManager inside of my master page and I have enabledPartialRendering set to true.  Now when I browse to the page in IE 7, I press the enter key and the button is fired and page does what it is supposed to do.  When I browse to the same page using Firefox 2.0.0.4 and press the enter key, my page posts back, but the button's click event is not fired.  I changed my asp:ImageButton control to an asp:Button control and I experienced the same results with FireFox.  I also, ran debugger to examine the Request.Forms key collection and noticed that the button WAS NOT in it.  At the very end of the collection there was a null item.  I ran the same code using IE 7 and when I examined the Form's collection I noticed that my button WAS in it just as I expected it should have been.  If I click the button with my mouse in firefox the button is in the form's collection.  So it appears for some odd reason that the enter button is not keeping track of the button that should have been clicked.  When I disable partial page rendering everything works in both firefox and IE 7.


    I am also experiencing a very weird issue after pusing this to a production windows 2003 server.  In the paragraph above, I mentioned that the page operates as it should when viewing it in IE 7.  Well, when I go to the page on the production server I do experience another issue.  The enter button cause the submit button to fire, but only once.  I have to reload the page for it to work again.  There are a few pages where I have several default buttons set.  When I browse to those pages on the production server the first press of the enter button fires as expected.  Subsequent presses of the enter key cause sporadic results.  For example, if my cursor is in a text box inside of panel 1 and I press the enter key then panel 2's default button is suddenly fired.  Again, this is only happening on a Windows 2003 server.  I think this issue is different from the above issue but just in case they are related I wanted to get it out.


    If anyone has an idea on what to do here, please help.  Thanks!!!

    Wednesday, June 13, 2007 3:43 PM

Answers

  • User717450801 posted

    Dave, thanks for testing.  I did see the suggestion for using the UseSubmitBehavior="false" but I didn't see that option for imagebuttons or linkbuttons but I may be mistaken.  Our site is using imagebuttons and linkbuttons exclusively so if this property isn't available to them then it won't help much, but at this point I will try anything.

    Thanks a lot for your code sample.  I will post this on the regular ajax forum as well.

    Chad

    You would have to use ImageButton's OnClientClick property

    OnClientClick="this.disabled=true;__doPostBack(this.name,'');"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 1, 2007 2:57 AM

All replies

  • User1225142132 posted
    Also, does anyone know if there is a codeplex issue regarding this type of behavior?
    Wednesday, June 13, 2007 6:24 PM
  • User1225142132 posted

    Ok, I created a very simple page for testing.  I am using a master page with my script manager being enabled there.  I cannot get firefox to work when when the Enter key is pressed when the script manager's EnablePartialRendering attribute is set to true.  Internet explorer works when partial rendering is on or off.

    Here is the markup for the page:

     
    1    <%@ Page Language="C#" MasterPageFile="~/DrLinkMaster.master" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" Title="Untitled Page" %>
    2    <asp:Content ID="Content1" ContentPlaceHolderID="cp" Runat="Server">
    3        <asp:UpdatePanel ID="udpSearchCriteria" runat="server" UpdateMode="conditional">
    4            <ContentTemplate>
    5                <asp:Panel ID="pnlTest" runat="server" DefaultButton="bSearch">
    6                    <div>
    7                        <asp:TextBox ID="txtTest" runat="server" Text="Test" />
    8                    </div>
    9                    <div class="mainButtonContainer">
    10                       <asp:Button ID="bCancel" runat="server" Text="Cancel" OnClick="bCancel_Click" />
    11                       <asp:Button ID="bSearch" runat="server" Text="Search" OnClick="bSearch_Click" />
    12                   </div>
    13               </asp:Panel>
    14           </ContentTemplate>
    15       </asp:UpdatePanel>
    16   </asp:Content>
    
      
    Here is the code behind:
     
    1        protected void bCancel_Click(object sender, EventArgs e)
    2        {
    3            txtTest.Text = "Cancel Clicked at " + DateTime.Now;
    4        }
    5    
    6        protected void bSearch_Click(object sender, EventArgs e)
    7        {
    8            txtTest.Text = "Search Clicked at " + DateTime.Now;
    9        }
     
    Markup inside of my master page.  First line after my form tag:
     
    1    <ajaxToolkit:ToolkitScriptManager ID="tsm" runat="server" EnablePartialRendering="true" />
    
     
     
    Also, if I remove the asp:UpdatePanel and ContentTemplate tags then firefox works but of course with normal postbacks.  I hope someone can tell me what's going on here.
    
      
    Thursday, June 14, 2007 10:33 AM
  • User-1429816726 posted

    I see the same problem you are - even with no Toolkit stuff in the page at all. It seems like the _Click handlers on the server-side aren't getting called for some reason. You should probably post this question to one of the ASP.NET AJAX (non-Toolkit) forums since they may have a better idea what the cause is.

    PS - Here's a single-page non-Toolkit demonstration based on what you had above:

     

    <%@ Page Language="C#" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        protected void bCancel_Click(object sender, EventArgs e)
        {
            txtTest.Text = "Cancel Clicked at " + DateTime.Now;
        }
    
        protected void bSearch_Click(object sender, EventArgs e)
        {
            txtTest.Text = "Search Clicked at " + DateTime.Now;
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <asp:ScriptManager ID="sm" runat="server" EnablePartialRendering="true" />
                <asp:UpdatePanel ID="udpSearchCriteria" runat="server" UpdateMode="conditional">
                    <ContentTemplate>
                        <asp:Panel ID="pnlTest" runat="server" DefaultButton="bSearch">
                            <div>
                                <asp:TextBox ID="txtTest" runat="server" Text="Test" />
                            </div>
                            <div class="mainButtonContainer">
                                <asp:Button ID="bCancel" runat="server" Text="Cancel" OnClick="bCancel_Click" />
                                <asp:Button ID="bSearch" runat="server" Text="Search" OnClick="bSearch_Click" />
                            </div>
                        </asp:Panel>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </form>
    </body>
    </html>
    
     
    Friday, June 15, 2007 7:55 PM
  • User-1429816726 posted

    A quick search ("firefox defaultbutton") suggests that setting UseSubmitBehavior="False" may solve your problem: http://forums.asp.net/p/1109931/1707008.aspx#1707008

     

    Friday, June 15, 2007 7:59 PM
  • User1225142132 posted

    Dave, thanks for testing.  I did see the suggestion for using the UseSubmitBehavior="false" but I didn't see that option for imagebuttons or linkbuttons but I may be mistaken.  Our site is using imagebuttons and linkbuttons exclusively so if this property isn't available to them then it won't help much, but at this point I will try anything.

    Thanks a lot for your code sample.  I will post this on the regular ajax forum as well.

    Chad

    Friday, June 15, 2007 8:14 PM
  • User1225142132 posted

    David, I tested this and the UseSubmitBehavior="False" does make that page work when using firefox.  However, after further testing, it doesn't work for image buttons.  I posted in the other forum as you suggested at http://forums.asp.net/p/1122767/1759690.aspx#1759690.  Do you have any other suggestions?

     Thanks,

    Chad

    Monday, June 18, 2007 9:55 AM
  • User717450801 posted

    Dave, thanks for testing.  I did see the suggestion for using the UseSubmitBehavior="false" but I didn't see that option for imagebuttons or linkbuttons but I may be mistaken.  Our site is using imagebuttons and linkbuttons exclusively so if this property isn't available to them then it won't help much, but at this point I will try anything.

    Thanks a lot for your code sample.  I will post this on the regular ajax forum as well.

    Chad

    You would have to use ImageButton's OnClientClick property

    OnClientClick="this.disabled=true;__doPostBack(this.name,'');"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 1, 2007 2:57 AM
  • User1225142132 posted

    Thanks Javier, that acutally works.  On my small test app I used this.id in place of this.name and it seemed to work as well.  Is there reason to use this.name over this.id?  And how did you discover this trick? 

     

    Thanks,
    Chad

    Wednesday, August 1, 2007 10:06 AM
  • User161227716 posted

    Hello ,

    Use Below line in Page load it will solve problem in firefox

    if(!IsPostback)  

    {

    txtSearch.Attributes.Add("onkeydown", "if (event.keyCode==13){document.getElementById('" + btnSearch.ClientID + "').focus();return true;}")

    }<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
    Friday, April 25, 2008 9:02 AM