Solved

Firing an event on a button control inside a table control  vb.net

Posted on 2009-05-19
4
373 Views
Last Modified: 2013-11-08
i need to wriite a sub  to be fired when the buttin clicked, But it seems that when the control is inside a table control cannot be accessed directlly
e.g.
Protected Sub SendPax_Click  
some code
end sub
<asp:Table ID="PaxTable" runat="server" Width="344px" Height="32px">

  <asp:TableHeaderRow><asp:TableHeaderCell ColumnSpan="5">Please enter passenger names</asp:TableHeaderCell>

        </asp:TableHeaderRow>

      

      

      <asp:TableFooterRow>

      <asp:TableCell HorizontalAlign="right">

          <asp:Button ID="SendPax" runat="server" Text="Send" />  &nbsp;

      </asp:TableCell>

      </asp:TableFooterRow>

     </asp:Table>
 

VB code
 

Dim Row As Integer

        Dim Col As Integer
 
 

        For Row = 1 To PAX
 

            Dim newRow As New TableRow

            newRow = New TableRow

            For Col = 0 To 3

                Dim newCell = New TableCell

                If Col = 0 Then

                    newCell.Text = Row

                ElseIf Col = 1 Then

                    Dim txtbox As New TextBox

                    txtbox.ID = "First" & Row

                    newCell.controls.add(txtbox)

                ElseIf Col = 2 Then

                    Dim txtbox As New TextBox

                    txtbox.ID = "Last" & Row

                    newCell.controls.add(txtbox)

                End If

                newRow.Cells.Add(newCell)

            Next Col

            PaxTable.Rows.Add(newRow)

            newRow = Nothing
 

        Next Row

Open in new window

0
Comment
Question by:Nabilbahr
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
JackOfPH earned 250 total points
ID: 24428386
Advice....

Instead of putting the code inside the button event, put it in the a new sub. In this way you do not need to call the event, but instead you call the sub routine.

For example:

Protected Sub SendPax_Click
        ExecuteCode
End Sub

Protected Sub ExecuteCode()
   'Your code when the Button was clicked.
End Sub
0
 

Author Comment

by:Nabilbahr
ID: 24428399
my concern is to be able to run some code when the button is clicked
How to catch an the click event and run some code when clicked
the control is inside a table control
0
 

Author Comment

by:Nabilbahr
ID: 24428467
thank you , you were right
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24428473
Set the modifier property of the button to Public.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now