I have a @Url.Action ASP.NET Method that looks similar to the code below:
<h1 class="sidebar-item custom-heading" id="heading-info" href="#">*Dynamically Changing Header*</h1>
<a class="sidebar-item" onclick="javascriptFunction()" href="@Url.Action("Action", "Controller", new {
name="Dynamically Changing Header",
})">Link</a>
With The Controller Method looking similar to this:
public IActionResult Action(string name) {
// operation
}
My issue I'd like to send the text inside the h1 tag(id="heading-info") to the controller. It's dynamic because a there's a java-script function that changes the innerText when called, however that shouldn't be an issue. Ideally, what I'd want is for whatever text is in between that h1 tag to be sent to the controller whenever that link is clicked. That value will later be validated by the controller.
Let me know if this is at all possible.
EDIT:
This link also handles some properties that should not be seen by the user. The new example is below:
<h1 class="sidebar-item custom-heading" id="heading-info" href="#">*Dynamically Changing Header*</h1>
<a class="sidebar-item" onclick="javascriptFunction()" href="@Url.Action("Action", "Controller", new {
// Does not matter if seen by client
name="Dynamically Changing Header",
// Should not be seen by Client
importantPieceOfData1=@ViewBag.Piece1,
importantPieceOfData2=@ViewBag.Piece2,
importantPieceOfData3=@ViewBag.Piece3,
})">Link</a>
So now the controller should look like this:
public IActionResult Action(string name, string importantPieceOfData1, string importantPieceOfData2, string importantPieceOfData3) {
// operation
}
Again, all I need is whatever text is in between that h1 tag to be sent to the controller whenever that link is clicked along with the attached server side code that shouldn't be seen.