简体   繁体   中英

switch Tab in VB on button click

I am creating tabs with div and javascript

<div  id="tabs"> 
    <ul class="nav nav-tabs">
        <li><a href="#tabs-1">Issue Part</a></li>
        <li><a href="#tabs-2">Return Part</a></li>

    </ul>
    <div id="tabs-1" > Content </div>
   <div id="tabs-2" > Content </div>

</div>

In tab1 and tab2 I have gridview and search buttons, when I click search button on tab 2, it filters the data of gridview2 on tab2 but displays tab1 how can I explicitly add after button click to show tab2

Button Click Code

    Protected Sub ImageButton2_Click(sender As Object, e As ImageClickEventArgs) Handles ImageButton2.Click
        Dim DataView As New DataView(PopulatePR())
        If (DropDownList2.Text = "OR") Then
            DataView.RowFilter = "Case = '" + Txtcase1.Text + "' OR Name = '" + txtname1.Text + "'"
        Else
            DataView.RowFilter = "Case = '" + Txtcase1.Text + "' AND Name = '" + txtname1.Text + "'"
        End If
        GridView2.DataSource = DataView
        GridView2.DataBind()

End Sub

I tried with this but it is not working

  MyBase.OnPreRender(e)
        Page.ClientScript.RegisterStartupScript(GetType(Issue_Parts),"TabToSelect", "$('#tabs').tabs({ active:1})", True)

I think somewhere in the control events of the dataGridView tab 1 is being selected. Since it is not possible for the program to do it on its on accord. I strongly recommend that you find where that piece of code is that is causing the bug.

As for how you can explicitly select tab 2. You do it by using the added line I did to select tab2 within you ButtonClick event. But this is just a kludge for time being. It is once again strongly recommended to find the piece of code that is selecting tab1.

    Protected Sub ImageButton2_Click(sender As Object, e As ImageClickEventArgs) Handles ImageButton2.Click
          Dim DataView As New DataView(PopulatePR())
          If (DropDownList2.Text = "OR") Then
              DataView.RowFilter = "Case = '" + Txtcase1.Text + "' OR Name = '" + txtname1.Text + "'"
          Else
              DataView.RowFilter = "Case = '" + Txtcase1.Text + "' AND Name = '" + txtname1.Text + "'"
          End If
          GridView2.DataSource = DataView
          GridView2.DataBind()
          tabControl1.SelectedTab = tabPage2
    End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM