Skip to main content
Answer

How to know currently selected Tab in code level?

  • November 18, 2024
  • 3 replies
  • 76 views

Forum|alt.badge.img

Hi Community,

Can you please help me with the sample to know which tab is selected.

 

Best answer by Dmitrii Naumov

@nsmith51 I don’t think this data is transferred to the backend. So, I don’t think there is a way. 

 

@Mary06 this is not a correct code.

3 replies

Mary06
Freshman II
  • Freshman II
  • November 18, 2024

Hello ​@nsmith51,

 

To find the currently selected tab in code, you can use the PXTab control. In your graph, override the RowSelected event and access the SelectedTab property of the tab control.

The example could be:  

```csharp
protected void YourDAC_RowSelected(PXCache cache, PXRowSelectedEventArgs e)  
{  
    if (e.Row == null) return;  
    var tabControl = PXPage.GetControl<PXTab>("YourTabControlID");  
    if (tabControl != null)  
    {  
        string selectedTab = tabControl.SelectedTab;  
        PXTrace.WriteInformation($"Currently selected tab: {selectedTab}");  
    }  
}
```  

Also make sure the tab control in your ASPX file has a proper ID:  
```xml
<px:PXTab ID="YourTabControlID" runat="server">
    <Items>
        <px:PXTabItem Text="Tab1" />
        <px:PXTabItem Text="Tab2" />
    </Items>
</px:PXTab>
```  
Deploy the changes, and this will let you track the active tab dynamically. Hope it helps


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • Answer
  • November 18, 2024

@nsmith51 I don’t think this data is transferred to the backend. So, I don’t think there is a way. 

 

@Mary06 this is not a correct code.


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • November 18, 2024

Thank you for your input @Dmitrii Naumov!

@Mary06 you may have used AI to assist with your response. If so, please note the below. Thank you!