In my app, we have master page which has some common features like export to excel, pdf etc.
On content page, I have TabContainer with multiple tabs.
When I run option like export to excel, Master page calls exportExcel function on content page. Based on active tab, I run different logic to export the data. Fields are different on each tab so separate logic is needed.
var activeTab = TabContainer.ActiveTab;
if (activeTab == abc_Tab)
{
//some logic
}
else if (activeTab == def_Tab)
{
//some logic
}
else if (activeTab == ghi_Tab)
{
//some logic
}
else if (activeTab == jkl_Tab)
{
//some logic
}
This code is working Perfectly fine. The problem is, this if-else logic is repeatative with every master page feature. If I add new feature like export to csv, ExportCsv functiona will also have this if-else condition. This is not limited to export functionality. sometimes, I need to pass some data/parameter also and based on active those, those data/parameter interpret differently.
Is there any better way to handle this?