Answer the question
In order to leave comments, you need to log in
How to bind link/button behavior to a specific class instance?
There is such a class:
public class Profile
{
public static readonly List<Profile> Profiles = new()
{
new Profile("Profile #1", "0.0.0.0"),
new Profile("Profile #2", "0.0.0.0"),
new Profile("Profile #3", "0.0.0.0"),
new Profile("Profile #4", "0.0.0.0"),
new Profile("Profile #5", "0.0.0.0")
};
public string ProfileName { get; set; }
public string IpAddress { get; set; }
private Profile(string profileName, string ipAddress)
{
ProfileName = profileName;
IpAddress = ipAddress;
}
}
@foreach (var item in Profile.Profiles)
{
<div>
<h1>@item.ProfileName</h1>
<h4>@item.IpAddress</h4>
<a href="#">Do something</a>
</div>
}
Answer the question
In order to leave comments, you need to log in
I didn’t understand the task a little, so I’ll give an answer to what I understood)
First, try using JS if you need to change “Something” depending on “Something”, but this, as you understand, works, if you need changes on the view (Even Vue.js is better here).
Second, try using other classes for such tasks. Here you will already need (Probably) Ajax to work correctly with views. Through Ajax, try to redirect the click "Somewhere" and process it there
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question