472,371 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 software developers and data experts.

asp:button does not fire event when placed inside asp:table

I had a beautiful script that was running, well, just beautifully. But
then I decided to take a button that fired an event and place it inside
a <asp:table. The event WILL NOT FIRE INSIDE THE TABLE!?! When I move
the button outside the table, it works just fine. Inside the table, it
doesn't. What gives?

Nov 19 '05 #1
8 3752
WJ
Check the HTML tab to make sure that the Button control that fires the event
is placed inside <FORM>....</FORM>. Or perhaps, the "<asp:table" is not
within the "Form" boundary.

John

<ta*********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I had a beautiful script that was running, well, just beautifully. But
then I decided to take a button that fired an event and place it inside
a <asp:table. The event WILL NOT FIRE INSIDE THE TABLE!?! When I move
the button outside the table, it works just fine. Inside the table, it
doesn't. What gives?

Nov 19 '05 #2
Hi,

Post the table markup. There are many reasons. You could be missing a
quote or a bracket. If you cut and paste the button then the ID will
automatically change if you don't erase the button from where it was first.
Check that you have matching opening/closing cell and row brackets. If it
is a large table then create a small one row one cell table. Put the button
in there and make sure it fires. Once you have gained that confidence and
seen it work then start creating your larger table piece by piece until your
button stops working. Whatever you just did before it stopped working is
where your problem is. Be sure to post code or markup next time and you
will receive a much more accurate answer. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

<ta*********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I had a beautiful script that was running, well, just beautifully. But
then I decided to take a button that fired an event and place it inside
a <asp:table. The event WILL NOT FIRE INSIDE THE TABLE!?! When I move
the button outside the table, it works just fine. Inside the table, it
doesn't. What gives?

Nov 19 '05 #3
The button is definitely still inside the form, and nothing is being
erased and/or left behind when I move the button in and out of the
table. The procedure of moving the button isn't exactly what you'd
call complex. All I do is drag and drop the <asp:button> code in the
HTML viewer. The code behind the scenes still sees the button. I can
still reference and make visual changes to it. So the object is not
being hidden inside a <table> class somewhere. Why don't the events
fire?

Nov 19 '05 #4
Hi,

Post the code. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

<ta*********@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
The button is definitely still inside the form, and nothing is being
erased and/or left behind when I move the button in and out of the
table. The procedure of moving the button isn't exactly what you'd
call complex. All I do is drag and drop the <asp:button> code in the
HTML viewer. The code behind the scenes still sees the button. I can
still reference and make visual changes to it. So the object is not
being hidden inside a <table> class somewhere. Why don't the events
fire?

Nov 19 '05 #5
Ok, here is a sample script I created called test.aspx that shows what
I'm taking about. It's in two parts, the aspx and aspx.cs. Click the
button in the first box... and it works. The second one is exactly the
same except it's inside an <asp:table> and it doesn't work. The third
button will make changes to the objects in the <asp:table>.

//test.aspx
<%@ Page language="c#" Codebehind="test.aspx.cs"
AutoEventWireup="false" Inherits="cafgss.test" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>test</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<P>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:Button id="Button1" runat="server" Text="Button Outside
Table"></asp:Button></P>

<asp:Table id="Table1" runat="server" GridLines="Both"
CellPadding="5" BorderStyle="Solid"
BorderColor="Black">
<asp:TableRow>
<asp:TableCell>
<asp:TextBox runat="server" ID="TextBox2"></asp:TextBox>
<asp:Button runat="server" ID="Button2" Text="Button Inside
Table"></asp:Button>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
<P>
<asp:Button id="Button3" runat="server" Text="Tease
Box"></asp:Button></P>
</body>
</HTML>

//test.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace cafgss
{
/// <summary>
/// Summary description for test.
/// </summary>
public class test : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Table Table1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.Button Button3;
protected System.Web.UI.WebControls.Button Button1;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Button3.Click += new System.EventHandler(this.Button3_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void Button1_Click(object sender, System.EventArgs e)
{
TextBox1.Text = "This works!";
}

private void Button2_Click(object sender, System.EventArgs e)
{
TextBox2.Text = "Does this one work?";
}

private void Button3_Click(object sender, System.EventArgs e)
{
TextBox2.Text = "I can play in the box";
Button2.Text = "I can reference you";
}
}
}

Nov 19 '05 #6
Hi,

Add this line between the other two in the InitializeComponent function:

this.Button2.Click += new System.EventHandler(this.Button2_Click);
By the way your Button3 is outside of your <Form> tags. Put it above the
</Form> tag or you'll have more problems. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

<ta*********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Ok, here is a sample script I created called test.aspx that shows what
I'm taking about. It's in two parts, the aspx and aspx.cs. Click the
button in the first box... and it works. The second one is exactly the
same except it's inside an <asp:table> and it doesn't work. The third
button will make changes to the objects in the <asp:table>.

//test.aspx
<%@ Page language="c#" Codebehind="test.aspx.cs"
AutoEventWireup="false" Inherits="cafgss.test" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>test</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<P>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:Button id="Button1" runat="server" Text="Button Outside
Table"></asp:Button></P>

<asp:Table id="Table1" runat="server" GridLines="Both"
CellPadding="5" BorderStyle="Solid"
BorderColor="Black">
<asp:TableRow>
<asp:TableCell>
<asp:TextBox runat="server" ID="TextBox2"></asp:TextBox>
<asp:Button runat="server" ID="Button2" Text="Button Inside
Table"></asp:Button>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
<P>
<asp:Button id="Button3" runat="server" Text="Tease
Box"></asp:Button></P>
</body>
</HTML>

//test.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace cafgss
{
/// <summary>
/// Summary description for test.
/// </summary>
public class test : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Table Table1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.Button Button3;
protected System.Web.UI.WebControls.Button Button1;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Button3.Click += new System.EventHandler(this.Button3_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void Button1_Click(object sender, System.EventArgs e)
{
TextBox1.Text = "This works!";
}

private void Button2_Click(object sender, System.EventArgs e)
{
TextBox2.Text = "Does this one work?";
}

private void Button3_Click(object sender, System.EventArgs e)
{
TextBox2.Text = "I can play in the box";
Button2.Text = "I can reference you";
}
}
}

Nov 19 '05 #7
Thanks, that did help. I swear I tried that before though. After
playing with it a little more, it would appear that the events are
automatically removed by Visual Studio every single time I make a
change to the HTML page in design mode. It's most annoying. So my
next question is, can that be stopped? This pile of junk is deleting
code that I add!!! Talk about nerve!

Nov 19 '05 #8
I'll suggest you to check if there is any item left in the"job list"(I'm
using Chinese version so you should find similiar name in English)
The IDE will find certain possible problem and add them there. If something
is left then the designer view can have problem to switch back to your code
view, and doing unsensible changes to your code because somehow you made it
think the changes make senses.

<ta*********@gmail.com> ???
news:11**********************@g14g2000cwa.googlegr oups.com ???...
Thanks, that did help. I swear I tried that before though. After
playing with it a little more, it would appear that the events are
automatically removed by Visual Studio every single time I make a
change to the HTML page in design mode. It's most annoying. So my
next question is, can that be stopped? This pile of junk is deleting
code that I add!!! Talk about nerve!

Nov 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Stephen | last post by:
I have the below asp table and I would like to be able to call up the lblAddress1 label with in the asp table in the code behind page. I tried doing this.lblAddress1 and it didn't work and I tried...
2
by: Kevin | last post by:
I am just learning asp.net and ran into a problem that I have not been able to resolve. I have a web form with an html table that houses an asp:label, asp:textbox and asp:button within. I had the...
3
by: Marty McDonald | last post by:
I have <asp:Table... </asp:Table> on my webform. In codebehind, I populate a DataTable whose data should appear in the asp:Table. I created my own code to populate the asp:Table with the...
4
by: coleenholley | last post by:
I asked the question yesterday: > HI All :-) > > I don't know if I will be able to do this type of formatting, but what I > need to do is have a table row where the text wraps (This is easy)...
1
by: Ed West | last post by:
Hello, How can I put a textbox control into a cell of an asp:Table? I was not able to do it from the properties sheet, so I put it in via html tab, but now I can't select it from the Design tab...
4
by: hb | last post by:
Hi, When I add an asp:button (ex: id=btnLog) on home.aspx, I need to create btnLog_Click() event in home.aspx.cs, and also link this event and the button in OnInit() method by adding:...
0
by: Davey P | last post by:
I have an asp.net table which I am populating with controls dynamically at runtime. The controls themselves get/set values in a datatable which is stored in viewstate over postbacks. Here is...
4
by: keithb | last post by:
It looks like the span tag cannot be used with asp tables. What is the best way to make an irregular asp table? Thanks, Keith
1
by: jonnyboy26 | last post by:
I have a dynamically populated ASP table. One of the columns in every row is a checkbox. I want the user to be able to check a few of the boxes, then hit the 'update' button. Thus marking the records...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.