473,394 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Button Event Inside Table

I can't get my button event to fire inside a table. the button outside of
the table works. Both make a postback.

Any help appreciated.

My code below.
(Add button to page)

Dim myButton As New Button

myButton.ID = ButtonID.ToString

myButton.Text = "Save"

Page.FindControl("FORM1").Controls.Add(myButton)

AddHandler myButton.Click, AddressOf btnAdd_Click

(Add button to table cell)

Dim myButton As New System.Web.UI.WebControls.Button

myButton.ID = myDate.ToShortTimeString

myButton.Text = myDate.ToShortTimeString

myCell1.Controls.Add(myButton)

AddHandler myButton.Click, AddressOf btnAdd_Click

(Event)

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)

Dim myButton As Button

myButton = CType(sender, Button)

Dim myTemp As String = myButton.ID

End Sub
Nov 18 '05 #1
4 1960
Bishop,
The thing that stands out to me is that you are setting the Button ID to
a date? This is probably changing from postback to postback. Events are
wired up based on the uniqueID of each control, so this must remain the same
from postback to postback. Another thing I see wrong is that you are
setting properties before you add the control to the page. You should add
the control to the page (or table cell) before you set any properties.

Best regards,
Jeffrey Palermo

"Bishop" <kw****@new.rr.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
I can't get my button event to fire inside a table. the button outside of
the table works. Both make a postback.

Any help appreciated.

My code below.
(Add button to page)

Dim myButton As New Button

myButton.ID = ButtonID.ToString

myButton.Text = "Save"

Page.FindControl("FORM1").Controls.Add(myButton)

AddHandler myButton.Click, AddressOf btnAdd_Click

(Add button to table cell)

Dim myButton As New System.Web.UI.WebControls.Button

myButton.ID = myDate.ToShortTimeString

myButton.Text = myDate.ToShortTimeString

myCell1.Controls.Add(myButton)

AddHandler myButton.Click, AddressOf btnAdd_Click

(Event)

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)

Dim myButton As Button

myButton = CType(sender, Button)

Dim myTemp As String = myButton.ID

End Sub

Nov 18 '05 #2
Thanks for the advice.

The dates are pulled from a DB and are always going to be the same.

I tried moving the properties after adding the control but didn't make any
difference.


"Jeffrey Palermo [MCP]" <http://dotnetjunkies.com/weblog/jpalermo> wrote in
message news:%2***************@TK2MSFTNGP12.phx.gbl...
Bishop,
The thing that stands out to me is that you are setting the Button ID to a date? This is probably changing from postback to postback. Events are
wired up based on the uniqueID of each control, so this must remain the same from postback to postback. Another thing I see wrong is that you are
setting properties before you add the control to the page. You should add
the control to the page (or table cell) before you set any properties.

Best regards,
Jeffrey Palermo

"Bishop" <kw****@new.rr.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
I can't get my button event to fire inside a table. the button outside of the table works. Both make a postback.

Any help appreciated.

My code below.
(Add button to page)

Dim myButton As New Button

myButton.ID = ButtonID.ToString

myButton.Text = "Save"

Page.FindControl("FORM1").Controls.Add(myButton)

AddHandler myButton.Click, AddressOf btnAdd_Click

(Add button to table cell)

Dim myButton As New System.Web.UI.WebControls.Button

myButton.ID = myDate.ToShortTimeString

myButton.Text = myDate.ToShortTimeString

myCell1.Controls.Add(myButton)

AddHandler myButton.Click, AddressOf btnAdd_Click

(Event)

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)

Dim myButton As Button

myButton = CType(sender, Button)

Dim myTemp As String = myButton.ID

End Sub


Nov 18 '05 #3
Bishop,
If you can post a complete code sample that exhibits this behavior, it
may be more obvious. Get rid of all code that isn't relevant to the problem
at hand.

Best regards,
Jeffrey Palermo

"Bishop" <kw****@new.rr.com> wrote in message
news:Oh**************@TK2MSFTNGP12.phx.gbl...
Thanks for the advice.

The dates are pulled from a DB and are always going to be the same.

I tried moving the properties after adding the control but didn't make any
difference.


"Jeffrey Palermo [MCP]" <http://dotnetjunkies.com/weblog/jpalermo> wrote in message news:%2***************@TK2MSFTNGP12.phx.gbl...
Bishop,
The thing that stands out to me is that you are setting the Button ID
to
a date? This is probably changing from postback to postback. Events are wired up based on the uniqueID of each control, so this must remain the same
from postback to postback. Another thing I see wrong is that you are
setting properties before you add the control to the page. You should add the control to the page (or table cell) before you set any properties.

Best regards,
Jeffrey Palermo

"Bishop" <kw****@new.rr.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
I can't get my button event to fire inside a table. the button

outside of the table works. Both make a postback.

Any help appreciated.

My code below.
(Add button to page)

Dim myButton As New Button

myButton.ID = ButtonID.ToString

myButton.Text = "Save"

Page.FindControl("FORM1").Controls.Add(myButton)

AddHandler myButton.Click, AddressOf btnAdd_Click

(Add button to table cell)

Dim myButton As New System.Web.UI.WebControls.Button

myButton.ID = myDate.ToShortTimeString

myButton.Text = myDate.ToShortTimeString

myCell1.Controls.Add(myButton)

AddHandler myButton.Click, AddressOf btnAdd_Click

(Event)

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)

Dim myButton As Button

myButton = CType(sender, Button)

Dim myTemp As String = myButton.ID

End Sub



Nov 18 '05 #4
I figured out that if I use mydate.hour & myday.min instead of a formated
time, it works. I'm guessing it either didn't like the spaces or the ":" in
the ID. At least it works. thanks for the suggestions!

"Jeffrey Palermo [MCP]" <http://dotnetjunkies.com/weblog/jpalermo> wrote in
message news:%2******************@TK2MSFTNGP10.phx.gbl...
Bishop,
If you can post a complete code sample that exhibits this behavior, it
may be more obvious. Get rid of all code that isn't relevant to the problem at hand.

Best regards,
Jeffrey Palermo

"Bishop" <kw****@new.rr.com> wrote in message
news:Oh**************@TK2MSFTNGP12.phx.gbl...
Thanks for the advice.

The dates are pulled from a DB and are always going to be the same.

I tried moving the properties after adding the control but didn't make any
difference.


"Jeffrey Palermo [MCP]" <http://dotnetjunkies.com/weblog/jpalermo> wrote

in
message news:%2***************@TK2MSFTNGP12.phx.gbl...
Bishop,
The thing that stands out to me is that you are setting the Button ID
to
a date? This is probably changing from postback to postback. Events

are wired up based on the uniqueID of each control, so this must remain
the same
from postback to postback. Another thing I see wrong is that you are
setting properties before you add the control to the page. You should

add the control to the page (or table cell) before you set any properties.

Best regards,
Jeffrey Palermo

"Bishop" <kw****@new.rr.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
> I can't get my button event to fire inside a table. the button

outside
of
> the table works. Both make a postback.
>
> Any help appreciated.
>
> My code below.
>
>
> (Add button to page)
>
> Dim myButton As New Button
>
> myButton.ID = ButtonID.ToString
>
> myButton.Text = "Save"
>
> Page.FindControl("FORM1").Controls.Add(myButton)
>
> AddHandler myButton.Click, AddressOf btnAdd_Click
>
>
>
>
>
> (Add button to table cell)
>
> Dim myButton As New System.Web.UI.WebControls.Button
>
> myButton.ID = myDate.ToShortTimeString
>
> myButton.Text = myDate.ToShortTimeString
>
> myCell1.Controls.Add(myButton)
>
> AddHandler myButton.Click, AddressOf btnAdd_Click
>
>
>
> (Event)
>
> Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs)
>
> Dim myButton As Button
>
> myButton = CType(sender, Button)
>
> Dim myTemp As String = myButton.ID
>
> End Sub
>
>



Nov 18 '05 #5

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

Similar topics

1
by: Mariusz | last post by:
Hi, I would like to use shift button to select multiple rows in table but there seems to be problem with it. I have table rows inside the <a> tag so I can drag them and drop like in windows...
4
by: athlonman | last post by:
Hi all!! II'm trying to set the Text of a TextBox in "Form1" when I click a Button in a UserControl. My code is: : public class Form1 : System.Windows.Forms.Form { public...
2
by: Chris Fink | last post by:
Hello, I have a datalist that contains an asp button. I have the need to pass a value that is bound to my datalist along the button when the on_click event is fired. My datalist creates a button...
1
by: Big_Stu | last post by:
Hi all, I have an <asp:button> inside an <asp:table> and I am finding that the button click event doesn't fire at all! I have added the button to the initialize component event, and the table. ...
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...
0
by: sonic | last post by:
hello, I have this custom datagrid control, that inherits from DataGrid. In addition to datagrid, I am adding a "status" table under it, and another html button, which will trigger a new row. ...
8
by: tatemononai | last post by:
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...
2
by: gce | last post by:
Allthough button2 created with the designer works 100%. The button I created (inside the table) with dim button1 as new button doesn't give me a click event. Please help. Public Class WebForm8 ...
3
by: Peter Vermilye | last post by:
How can I dynamically create buttons and wire them to an event handler? I have seen how I can add buttons to an event handler that are pre-created as part of the codebehind using AddHandler, but I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.