Click here to Skip to main content
15,669,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Yes. I've gone through all the similar questions here and at SO. Yes, and all the Google links.

No, there's no javascript or other client side things going on.

No, there's no update panel.

But the Button does not fire the Click event unless the page has already been submitted once. Not even that the Submit button has been pushed...even the Cancel button, which does nothing but reload the page, makes the Submit button work.

All possible combinations of the UseSubmitBehavior and CausesValidation properties have been tried.

I'm looking for an abnormal cause, not an often-seen one.

I even created a new page. stripped everything down to barebones do-nothing and it STILL doesn't work.

Here's the ASPX code:

<html xmlns="">
<head runat="server">
    <link rel="stylesheet" type="text/css" href="PatientRounding.css" /></head>
    <form id="form1" runat="server">
            <asp:Label ID="lblCount" runat="server" Text=" responses added"></asp:Label>
        <asp:Panel runat="server" id="divQuestions" CssClass="MainDiv" >

            <asp:Button ID="btnQuit" runat="server" CssClass="PageButton" OnClick="btnQuit_Click" Text="Return to Start" />
            <asp:Button ID="btnCancel" runat="server" CssClass="PageButton" OnClick="btnCancel_Click" Text="Clear Answers" />
            <asp:Button ID="btnSubmit" runat="server" CssClass="PageButton" OnClick="btnSubmit_Click" Text="Submit Answers" />


Here's the aspx.cs code:
public partial class PatientQuestions : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)


        protected void Page_PreInit(object sender, EventArgs e)

        protected void btnSubmit_Click(object sender, EventArgs e)
            lblCount.Text = "Done";          

        protected void btnCancel_Click(object sender, EventArgs e)


        protected void btnQuit_Click(object sender, EventArgs e)
            Server.Transfer("Default.aspx", false);

What am I not seeing? Why do I have to reload the page before the code behind code works?

This happens whether I'm running on my desktop with IISExpress from within VS, or out on the web server.

What could possibly cause this?
Krunal Rohit 23-Nov-15 23:43pm    
Strange, but still check the workarounds from here[^].
Maybe it would help you.

jgakenhe 24-Nov-15 0:10am    
Your code looks good. I'd create another page and then check to see if the button clicks work. Most likely it is something minute or something wrong with the designer. Also, you might want to try it in different browsers.

1 solution


I never did find what was causing it.

I'm going to assume some leftover gunk somewhere other than the page files. Despite doing a "clean" and deleting the options file and such, it still wouldn't work.

I created a new project, then copied over all the code from the bad project...and it works just fine.

I need to retire. Soon.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900