?
Solved

ASP Button Event do not fire

Posted on 2008-10-20
10
Medium Priority
?
1,054 Views
Last Modified: 2013-12-17
Hi, I am doing a web site in ASP.NET 2.0 and +
Coding in C#.
I use Visual Studio 2008 and SQL 2005 for my database.

Ok here is my question (please see the Code snippet also)
ok so when I click on button it do absolutely nothing, no error, no action. nothing.
and yes my textbox is fine, the browser doesnt even 'tick' or work when we click on a button that works.  My inherits looks fine.. I try to put it on another ASPX page like Default.aspx
and the button still not work...

any ideas?
<!-- This is my snippet for .ASPX page -->
<%@ Page Language="C#" MasterPageFile="~/Template.master" AutoEventWireup="true"
    CodeFile="Contact.aspx.cs" Inherits="ZZ.Mysite.UI.Contact" 
    Title="Contact Us" 
%>
...
<asp:Button runat="server" ID="txtSubmit" Text="Send" OnClick="txtSubmit_Click" />
 
 
// This is my code-behind file
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;
using ZZ.Mysite;
 
namespace ZZ.MySite.UI
{
    public partial class Contact : BasePage
    {
        public void txtSubmit_Click(object sender, EventArgs e)
        {
                txtName.Text = "Testing Button";
        }
    }
}

Open in new window

0
Comment
Question by:PhilippeRenaud
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
10 Comments
 
LVL 6

Expert Comment

by:mirzas
ID: 22758212
What is txtName ?


try this code.
namespace ZZ.MySite.UI
{
    public partial class Contact : BasePage
    {
        public void txtSubmit_Click(object sender, EventArgs e)
        {
            Response.Write("Test Test test");
        }
    }
}

Open in new window

0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 22758221
By the way, please do not care about the mysite or mySite
I wrote it back here it wasnt a CopyPaste. in my code, it is all wrote the same : "MySite"
0
 
LVL 6

Expert Comment

by:AmarIs26
ID: 22758386
What kind of events are you overriding in the BasePage?
Sometime you can accidently remove the base.OnLoad reference etc which breaks the page event cycle. So can you post the events from BasePage? (For every overridden event in BasePage of the Page class you must call the base.EventName to ensure the Page class can move on to the next event in the page event lifecycle).
0
Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 22758604
ok first of all, the txtName is :
<asp:TextBox runat="server" ID="txtName" Width="100%" />

I tried the response.write, did nothing..

For the basePage. I am actually doing 2 things.
1 is for my themes if in future I want to able Theme Selection.
the other one is for highlighting controls:

using ....

namespace ZZ.Mysite.UI
{
    public class BasePage : System.Web.UI.Page
    {
        protected override void OnPreInit(EventArgs e)
        {
            string id = Globals.ThemesSelectorID;
            if (id.Length > 0)
            {
                if (this.Request.Form["__EVENTTARGET"] == id &&
                    !string.IsNullOrEmpty(this.Request.Form[id]))
                {
                    this.Theme = this.Request.Form[id];
                    this.Session["CurrentTheme"] = this.Theme;
                }
                else
                {
                    if (this.Session["CurrentTheme"] != null)
                        this.Theme = this.Session["CurrentTheme"].ToString();
                }
            }
            base.OnPreInit(e);
        }

        protected override void OnLoad(EventArgs e)
        {
            Helpers.SetInputControlsHighlight(this, "highlight", false);
            base.OnLoad(e);
        }

    }
}

0
 
LVL 6

Expert Comment

by:AmarIs26
ID: 22758789
Whats in the ="~/Template.master file?
Any code executing there that could prevent the click from occuring?
 
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 22758836
well in the MAsterPage I have all my template with HTML .. and placeHolders as usual..

in the code-behind I have nothing.
I just dont get it.

Of course I could scratch all the web site and restart completely and see but god..
0
 
LVL 6

Accepted Solution

by:
AmarIs26 earned 1500 total points
ID: 22758942
The only other thing i can see is that you are using namespaces in an asp.net 2 application. Now, we know that asp.net creates a partial file where we can add the code. But the other partial file that is generated by the compiler is the one that contains the control declarations. So i would suggest that you try to remove the namespaces so that all the code in these pages is in the default namespace.
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 22759470
Ok indeed but its a normal thing to put namespaces, I mean microsoft would have put that for us if we could not use them. Its not the first time I use Namespaces and my buttons were doing fine...
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 22759472
wouldnt*
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 22760244
anyway thanks I will leave it like that and reset from scratch.
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

777 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