0

This has to be simple. Still, I've noticed VS2012 acting very erratic - sometimes it won't generate the designer file entries for example. Has anyone got any idea what might be going on here? I've tried adding the button both in code and by dragging it onto the design surface. I've re-created the form several times to no avail.

Here's my code:

ASPX:

<asp:Button ID="Button1" runat="server" CssClass="submitButton" 
    OnClick="Submit_Click" Text="  Submit  "  />

CODE-BEHIND:

protected void Submit_Click(object sender, EventArgs e)
{
    if (Page.IsValid)
    {
        Response.Write("got to here...");
    }
}

DESIGNER:

protected global::System.Web.UI.WebControls.Button Button1;
IrishChieftain
  • 15,072
  • 7
  • 47
  • 90

1 Answers1

1

Remove OnClick="Submit_Click", and as ASAWYER said, go to designer and double click on that button. or In backend code select General dropdown, find your button and in Declaration dropdown select click evententer image description here

pyccki
  • 673
  • 8
  • 22
  • Maybe something else in your project, in web.config preventing your postback. Remove everything from a page or create a blank one. if this wont work. Create new Project and try that. oh and if you have master page, don't use it. – pyccki Oct 17 '12 at 14:06
  • It worked on another page, but never when I create this one from scratch. – IrishChieftain Oct 17 '12 at 14:07
  • 1
    Since i haven't seen your page, you have to comment line by line or comment out everything except this button. Also you may try to change from asp:button to asp:linkbutton ??? – pyccki Oct 17 '12 at 14:09
  • so asp:RequiredFieldValidator preventing postback, kicks in Validation. Try to change display to Display="Dynamic" also add this to button tag: CausesValidation="false"(if you want validation) or CausesValidation="true" (to enable). Also you can add ValidationSummary take a look here: http://www.w3schools.com/aspnet/showasp.asp?filename=demo_validationsum – pyccki Oct 17 '12 at 16:12
  • That seems to be the problem... had it set to "none"!! – IrishChieftain Oct 17 '12 at 16:15
  • 1
    Display: The display behavior for the validation control. Legal values are: **None (the control is not displayed. Used to show the error message only in the ValidationSummary control)** Static (the control displays an error message if validation fails. Space is reserved on the page for the message even if the input passes validation. Dynamic (the control displays an error message if validation fails. Space is not reserved on the page for the message if the input passes validation http://www.w3schools.com/aspnet/control_reqfieldvalidator.asp – pyccki Oct 17 '12 at 16:18