Is there an easier way to do this #26726
Answered
by
Ariansh
minoseah629
asked this question in
General
-
i was wondering if there was a way to do this page efficiently. instead of having 3 click methods, I want to have 1. is there a way to pass arguments into my click method? I got this error message when i tried: <ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link @((activeTab.Equals(-1))? "active" : "")" role="tab" aria-controls="proposal" aria-selected="true"
data-toggle="tab" href="#home"
@onclick="proposalClicked"
>Proposal</a>
</li>
<li class="nav-item">
<a class="nav-link @((activeTab.Equals(0))? "active" : "")" role="tab" aria-controls="Milestone 1" aria-selected="false"
@onclick="mileStone1Clicked"
data-toggle="tab" >Milestone 1</a>
</li>
<li class="nav-item">
<a class="nav-link @((activeTab.Equals(1))? "active" : "")" role="tab" aria-controls="contact" aria-selected="false"
@onclick="futureClicked"
data-toggle="tab" >Future</a>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade @((activeTab.Equals(-1))? "show active" : "")"
role="tabpanel" aria-labelledby="proposal-tab">
<article >
<ProjectProposal />
</article>
</div>
<div class="tab-pane fade @((activeTab.Equals(0))? "show active" : "")"
role="tabpanel" aria-labelledby="Milestone1-tab">
<article >
<Milestone1/>
</article>
</div>
<div class="tab-pane fade @((activeTab.Equals(1))? "show active" : "")"
role="tabpanel" aria-labelledby="future-tab"></div>
</div>
@code
{
public int activeTab = -1;
void clicked()
{
Console.WriteLine("clicked");
}
void proposalClicked()
{
activeTab = -1;
}
void mileStone1Clicked()
{
activeTab = 0;
}
void futureClicked()
{
activeTab = 1;
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
Ariansh
Oct 10, 2020
Replies: 1 comment 1 reply
-
If i understood correctly, a quick solution would be passing an enum or anything and check the method with a switch case. so the onclick method would be like ()=>clicked(MyEnum.proposal). check this
===========================================
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
minoseah629
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If i understood correctly, a quick solution would be passing an enum or anything and check the method with a switch case. so the onclick method would be like ()=>clicked(MyEnum.proposal). check this
===========================================