?
Solved

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

Posted on 2009-05-19
4
Medium Priority
?
385 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
JackOfPH earned 1000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

777 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