Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Button Event Inside Table

Reply
Thread Tools

Button Event Inside Table

 
 
Bishop
Guest
Posts: n/a
 
      11-26-2004
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


 
Reply With Quote
 
 
 
 
Jeffrey Palermo [MCP]
Guest
Posts: n/a
 
      11-26-2004
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" <(E-Mail Removed)> wrote in message
news:%23%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Bishop
Guest
Posts: n/a
 
      11-26-2004
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:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%23%(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
Jeffrey Palermo [MCP]
Guest
Posts: n/a
 
      11-26-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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:%(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news:%23%(E-Mail Removed)...
> > > 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
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Bishop
Guest
Posts: n/a
 
      11-26-2004
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:%23sU%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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:%(E-Mail Removed)...
> > > 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" <(E-Mail Removed)> wrote in message
> > > news:%23%(E-Mail Removed)...
> > > > 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
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
asp:button does not fire event when placed inside asp:table tatemononai@gmail.com ASP .Net 8 03-11-2005 09:13 AM
rendering Button inside Render() event, makes it loose its click event handler association sonic ASP .Net 1 01-07-2005 06:33 PM
image button click event fires before click event of button Purvi T ASP .Net 0 10-19-2004 06:19 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Building Controls 1 05-28-2004 06:23 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net 2 05-25-2004 11:45 PM



Advertisments