Search code examples
asp.netcode-behind

Why isn't my code-behind working properly?


Here's my code-behind file for a web form. I can't get certain arguments to work properly with my form.

    protected void btn_Submit_Click(object sender, EventArgs e)
    {//Enter arguments here...
    }
    protected void btn_Clear_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/ContentRequest/BMC_PR_Event.aspx", true);
    }
    protected void ShowForm()
    {
        Open.Visible = true;
        Success.Visible = false;
        Failure.Visible = false;
    }
    protected void ShowSuccess()
    {
        Open.Visible = false;
        Success.Visible = true;
        Failure.Visible = false;
    }
    protected void ShowFailure()
    {
        Open.Visible = false;
        Success.Visible = false;
        Failure.Visible = true;
    }

}

Here's the code I'm trying to get it to work with...

        <asp:Button TabIndex="12" Text="Submit Request" ID="Button1" CssClass="submit" OnClientClick="return validateForm();" runat="server" onclick="btn_Submit_Click"></asp:Button>
        <asp:Button TabIndex="13" Text="Clear Fields" ID="Button2" CssClass="clear" UseSubmitBehavior="false" runat="server" onclick="btn_Clear_Click"></asp:Button>
        <asp:Label ID="Label1" runat="server"></asp:Label>
    </div>
</asp:Panel>
    <asp:Panel ID="Success" Visible="false" runat="server">
        <div class="message"><p>Your submission was sucessful.</p><p>An email receipt has been sent to the address provided with the details of this request.</p><p>Thank you.</p></div>
    </asp:Panel>
    <asp:Panel ID="Failure" Visible="false" runat="server">
        <div class="message">
            <p>There was an error with your request.  If this persists, please report your trouble to _OHE Web Strategies.</p>

Not sure what else I can do here...

--Edit-- This is the error I get...

enter image description here


Solution

  • From the code you have pasted, i cannot see a Panel control with the ID 'Open'. Please do one of the following.

    1. If you need another Panel for the 'open' functionality, add another asp:Panel with the is 'Open'
    2. If you have removed the Open panel once you had, remove the code (from code behind in your case) related to that.

    Best of luck

    James