Go Premium for a chance to win a PS4. Enter to Win

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 555
  • Last Modified:

asp:Button onclick will not fire

I'm at a total loss here.  Here's the setup:

Got a master page with <form runat="server">... There is an ASP.NET-ized Google CSE Search bar on it which works fine.  Then there is a ContentPlaceHolder.

The child page has a simple form... 1 TextBox, 1 Button.

<asp:TextBox ID="morningEmail" runat="server" CssClass="formStyle" Columns="35" />
<asp:Button ID="morningButton" runat="server" Text="Sign Up" CssClass="formStyle" />
<asp:Label ID="morningStatus" runat="server" />

The code behind on the child page:

Sub morningSignUp(ByVal sender As Object, ByVal e As EventArgs) Handles morningButton.Click
        c.sql = "INSERT INTO morningEmailAlerts (eAddress) VALUES (@eAddress)"
        Dim cmd As New SqlCommand(c.sql, c.Conn)

        cmd.Parameters.AddWithValue("@eAddress", morningEmail.Text)


        morningStatus.Text = "Sign up complete!"
    End Sub

As I said, the Google bar works fine.  But the morningButton asp:Button does absolutely nothing when clicked.  No postback, no error code... I might as well be clicking white space.  Please help, this is extremely urgent.
1 Solution
Hi ,
put a break point inside the codeof that button
check whether any javascript is attched to that button
b u d d h a
mvarner2000Author Commented:
What is a break point exactly?

Here is the generated code from the child form:

<input name="ctl00$ContentPlaceHolder1$morningEmail" type="text" size="35" id="ctl00_ContentPlaceHolder1_morningEmail" class="formStyle" />

<input type="submit" name="ctl00$ContentPlaceHolder1$morningButton" value="Sign Up" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ContentPlaceHolder1$morningButton&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" id="ctl00_ContentPlaceHolder1_morningButton" class="formStyle" />
Could you please check that morningButton is declared in the code behind..

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

mvarner2000Author Commented:
nepali, I assume you mean a line like this?

Protected WithEvents morningButton As Button

If so, when I put that in I get:

Compiler Error Message: BC30260: 'morningButton' is already declared as 'Protected Dim WithEvents morningButton As System.Web.UI.WebControls.Button' in this class.

Source Error:

Line 8:  
Line 9:      Protected WithEvents morningButton As Button
Line 10:

yes.. That is what... I meant
So it is declared...
To check if the event method is fired.. you can either put a breakpoint and debug your code. or place a Response.Write("in button click"). Recompile and check. If you get this message on the browser then the event is getting fired. or else Copy the code in event metthod just remove and add the button again, set its event method and paste the code back into it.
mvarner2000Author Commented:
Got a break point put in, but nothing happens when I compile the code.  Loads the page up fine, still no response from the button at all.
remove and add the button again, set its event method and paste the code back into it.
mvarner2000Author Commented:
Done.  Still no dice.  Doubt it will help, but you can see it in action here:  http://dev.gastongazette.com

Search at the top works.
Morning News Signup does squat.
The url cannot be opened.  Maybe your firewall or web server blocked external request.
mvarner2000Author Commented:
Does it offer anyone any hits that mousing over the button changes the status bar to just say "default.aspx"?  I've never seen a button do that.
mvarner2000Author Commented:
*hip thrust of victory*

Should have caught this sooner.  The Google search bar has a RequiredFieldValidator on it and I didn't set up a separate validation group, so trying to click that button was firing a validator farther up the page.  Thanks for all the suggestions!!

(Points to nepali for effort)

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now