Philippe Renaud
asked on
ASP Button Event do not fire
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?
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";
}
}
}
ASKER
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"
I wrote it back here it wasnt a CopyPaste. in my code, it is all wrote the same : "MySite"
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).
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).
ASKER
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["__EVEN TTARGET"] == id &&
!string.IsNullOrEmpty(this .Request.F orm[id]))
{
this.Theme = this.Request.Form[id];
this.Session["CurrentTheme "] = this.Theme;
}
else
{
if (this.Session["CurrentThem e"] != null)
this.Theme = this.Session["CurrentTheme "].ToStrin g();
}
}
base.OnPreInit(e);
}
protected override void OnLoad(EventArgs e)
{
Helpers.SetInputControlsHi ghlight(th is, "highlight", false);
base.OnLoad(e);
}
}
}
<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["__EVEN
!string.IsNullOrEmpty(this
{
this.Theme = this.Request.Form[id];
this.Session["CurrentTheme
}
else
{
if (this.Session["CurrentThem
this.Theme = this.Session["CurrentTheme
}
}
base.OnPreInit(e);
}
protected override void OnLoad(EventArgs e)
{
Helpers.SetInputControlsHi
base.OnLoad(e);
}
}
}
Whats in the ="~/Template.master file?
Any code executing there that could prevent the click from occuring?
Any code executing there that could prevent the click from occuring?
ASKER
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..
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..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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...
ASKER
wouldnt*
ASKER
anyway thanks I will leave it like that and reset from scratch.
try this code.
Open in new window