views:

272

answers:

3

Hi,

I have a button which is not working when placed below two panels. If I move it above the panels, it works.

It works either way in Firefox. It does not work in IE 8

The button runs this code

protected void Button2_Click(object sender, EventArgs e)
    {
        panelForm.Enabled = true; //input panel
        panelOutput.Visible = false; //output panel
        Button1.Visible = true; //input panel button

    }

I have some workarounds, but was hoping to find the cause of the issue.

edit: here is the markup of the second panel and button. I've tried moving the button outside of the panel and get the same result.

<asp:Content ID="MainContent" Runat="Server" ContentPlaceHolderID="MainContentPlaceHolder">

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

<asp:TextBox ID="domainUserID" runat="server" Visible="false"></asp:TextBox>
<!-- gray bar and title -->
<table style="width:100%; border-style:none;">
    <tr>
        <td class="com_headline">
            SQL Emergency Request [Home]
        </td>
    </tr>
    <tr class="com_app_instructions">
        <td>
            <p>Words here</p>
        </td>
    </tr>
</table>
<!-- end title and gray bar -->



<asp:Panel ID="panelForm" runat="server" Visible="True" CssClass="myform">
<form method="post" action="Default.aspx" id="form">
<h1>Request Form</h1>
<p>Complete this form to be issued a login</p>


<table cellpadding="5px">
    <tr>


            <td>
                IR Number
                <br />

                <span class="small">Obtain your IR number from
                <a href="http://apps.server/SMART"&gt;SMART&lt;/a&gt;&lt;/span&gt;

            </td>
            <td>
                <asp:TextBox ID="txtIR" runat="server"></asp:TextBox>
            </td>
            <td>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                    ControlToValidate="txtIR" CssClass="errorMsg" 
                    ErrorMessage="Please Enter Your IR Number">
                </asp:RequiredFieldValidator>
            </td>
    </tr>   

    <tr>
            <td>
                Server 
                <br />
                <span class="small">MSSQL5 is supported for now</span>
            </td>
            <td>
                <asp:DropDownList ID="ddServer" runat="server" AutoPostBack="True" 
                    Enabled="False" onselectedindexchanged="ddServer_SelectedIndexChanged">
                    <asp:ListItem>DEVMSSQL05</asp:ListItem>
                    <asp:ListItem Selected="True">MSSQL05</asp:ListItem>
                </asp:DropDownList>

            </td>
            <td>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                    ControlToValidate="ddServer" CssClass="errorMsg" 
                    ErrorMessage="Please Choose A Server">
                </asp:RequiredFieldValidator>

            </td>
     </tr>
     <tr>
            <td>      
                Database 
                <br />
                <span class="small">You have the role of &#39;Analyst&#39; in these databases</span>
            </td>
            <td>
                <asp:DropDownList ID="ddDatabase" runat="server" AppendDataBoundItems="true" 
                    AutoPostBack="false" DataSourceID="DatabaseDropDownObjectDataSource" 
                    DataTextField="DatabaseName" DataValueField="DatabaseName" Width="150">
                </asp:DropDownList>

            </td>
            <td>

            </td>
     </tr>


                    <tr>
                        <td></td>
                        <td>
                            <asp:Button ID="Button1" runat="server" CssClass="com_btn_flat" 
                                onclick="Button1_Click" Text="Submit" />

                        </td>
                        <td>
                            <div id="loader">loading...</div>
                        </td>
                    </tr>


            </table>
        </form>
</asp:Panel>  

<asp:Panel ID="PanelError" runat="server" Visible="false" CssClass="errorPanel">
        <h1><asp:Label ID="txtErrorMsg" runat="server">error text</asp:Label></h1> 
</asp:Panel>
   <br />

<asp:Panel ID="panelOutput" runat="server" Visible="false" CssClass="panelOutput">

        <h1>
            <asp:Literal ID="Title" runat="server" Text=""/>
        </h1>
        <p>     
            <asp:Literal ID="Warning" runat="server" Text=""/>
        </p>
        <p>     
            <asp:Literal ID="LoginLifeHours" runat="server" Text=""/>
        </p>

        <p>
            <span class="important"> 
                <asp:Literal ID="Login" runat="server" Text="" />
            </span>
        </p>
        <p>     
            <span class="important">    
                <asp:Literal ID="PWD" runat="server" Text="" />
            </span>
        </p>
        <br />

        <p>   
            <asp:Button ID="Button2" runat="server" Text="Request Another Login" 
            onclick="Button2_Click" CssClass="com_btn_flat" />
        </p>



 </asp:Panel>

This is the button that is not responding in IE

<p>   
<asp:Button ID="Button2" runat="server" Text="Request Another Login" 
onclick="Button2_Click" CssClass="com_btn_flat" />
</p>
A: 

I noticed that you have a tag inside your first panel (panelForm). Also, I don't see a a tag with a runat="server" attribute (although, it could be in a master page). And it doesn't look like your button is inside a form (unless the master page has a form).

The problem is that you can only have one form on a page in Asp.NET WebForms. If you don't have any <form runat="server"> tags on your page, then you buttons will not fire any events on the code-behind.

KevnRoberts
I have one form on the page with a submit button. After the submit happens, the results are placed in this output panel and the form is deactivated. This button is then supposed to hide the output and re-enable the form.
Sam
+1  A: 

The sample code is Button2_Click, but your button markup outside of the panels has test_button_Click as the event handler? There are three buttons, so which one are you asking about, I assume the last?

Brian
+1 - I think it really is just that simple.
Mark Brittingham
Sorry, fixed that code - deleted that markup as it is not involved and was a test I was trying. Besides, if that were the problem, it wouldn't be working in FireFox, right?
Sam
True, though odd. As @Joel Harris mentioned, it coudl be the form tag within the page, ASP.NET does only like one form. Alternatively, to verify the issue, you can do one of two things: look at the markup and see that there is a __doPostBack('<button unique id>', ''); in the onclick client-side definition, which is what triggers the postback. Two, you can check Request.Form["__EVENTTARGET"] and Request.Form["__EVENTARGUMENT"] which is what is used to wire up events. This would help you validate the issue in IE.
Brian
+1  A: 

The problem is that you are using a <form> tag within your content page. The master page already includes a <form> tag and IE appears to be balking at the form within a form. When I removed the <form> tag from your aspx, the button handler ran under IE8.

Joel Harris
This is the solution. Thanks!
Sam