Solved

asp:Button onclick will not fire

Posted on 2006-12-01
11
501 Views
Last Modified: 2010-07-27
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)

        c.Conn.Open()
        cmd.ExecuteNonQuery()
        c.Conn.Close()

        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.
0
Comment
Question by:mvarner2000
11 Comments
 
LVL 13

Expert Comment

by:jeebukarthikeyan
ID: 18053584
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
0
 
LVL 3

Author Comment

by:mvarner2000
ID: 18053599
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" />
0
 
LVL 7

Expert Comment

by:nepali
ID: 18053602
Hi,
Could you please check that morningButton is declared in the code behind..

0
 
LVL 3

Author Comment

by:mvarner2000
ID: 18053623
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:

 
0
 
LVL 7

Expert Comment

by:nepali
ID: 18053651
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.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 3

Author Comment

by:mvarner2000
ID: 18053673
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.
0
 
LVL 7

Accepted Solution

by:
nepali earned 500 total points
ID: 18053729
remove and add the button again, set its event method and paste the code back into it.
0
 
LVL 3

Author Comment

by:mvarner2000
ID: 18053799
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.
0
 
LVL 16

Expert Comment

by:Edwin_C
ID: 18054059
mvarner2000
The url cannot be opened.  Maybe your firewall or web server blocked external request.
Edwin
0
 
LVL 3

Author Comment

by:mvarner2000
ID: 18054108
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.
0
 
LVL 3

Author Comment

by:mvarner2000
ID: 18054134
*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)
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now