Ok, also versuche ich, einige generische Komponenten zu erstellen, aber ich habe einige Probleme, die den ASPFOR -Wert in der .cshtml < /p>
übergeben habe. Ich habe ein Eingabemodell und das teilweise < /p>
erstellt
public class InputModel : ComponentModel
{
public string AspFor { get; set; }
public string Value { get; set; }
public string? Disabled { get; set; }
}
public class ComponentModel
{
public string Id { get; set; }
public string Label { get; set; }
public bool IsMandatory { get; set; }
public ComponentEnum Componente { get; set; }
}
< /code>
public enum ComponentEnum
{
Input
}
public static class ComponentEnumExtensions
{
public static string GetPath(this ComponentEnum component)
{
return component switch
{
ComponentEnum.Input => "*Path_To_Input.cshtml*"
_ => string.Empty
};
}
}
< /code>
@(Model.Label)
@if (Model.IsMandatory)
{
(Mandatory)
}
@Model.Label
< /code>
i am then creating an instance of the input model and rendering it in the page with this model:
public class RegistoViewModel
{
public Contactos Contactos { get; set; }
}
public class Contactos
{
[Required(ErrorMessage = "Email is required")]
[EmailAddress(ErrorMessage = "Invalid email address")]
public string Email { get; set; } = string.Empty;
}
< /code>
@{
var input = new InputModel
{
Id = "inputId",
Label = "Email",
Componente = ComponentEnum.Input,
AspFor = "Contactos.Email",
Value = Model.Contactos.Email
};
}
@await Html.PartialAsync(ComponentEnum.Input.GetPath(), input)
< /code>
can someone help me understand how can i pass the AspFor dynamicaly and be able to create a generic InputModel
when i create the Div directly in the page it works ok:
@(Model.Test.Label)
@if (Model.Test.IsMandatory)
{
(Obrigatório)
}
Email
< /code>
public class RegistoViewModel
{
public Contactos Contactos { get; set; }
public InputModel Test{ get; set; }
}
public class Contactos
{
[Required(ErrorMessage = "Email is required")]
[EmailAddress(ErrorMessage = "Invalid email address")]
public string Email { get; set; } = string.Empty;
}
Ok, also versuche ich, einige generische Komponenten zu erstellen, aber ich habe einige Probleme, die den ASPFOR -Wert in der .cshtml < /p> übergeben habe. Ich habe ein Eingabemodell und das teilweise < /p> erstellt[code]public class InputModel : ComponentModel { public string AspFor { get; set; } public string Value { get; set; } public string? Disabled { get; set; } } public class ComponentModel { public string Id { get; set; } public string Label { get; set; } public bool IsMandatory { get; set; } public ComponentEnum Componente { get; set; } } < /code> public enum ComponentEnum { Input }
public static class ComponentEnumExtensions { public static string GetPath(this ComponentEnum component) { return component switch { ComponentEnum.Input => "*Path_To_Input.cshtml*" _ => string.Empty }; } }
< /code> i am then creating an instance of the input model and rendering it in the page with this model: public class RegistoViewModel { public Contactos Contactos { get; set; } }
public class Contactos { [Required(ErrorMessage = "Email is required")] [EmailAddress(ErrorMessage = "Invalid email address")] public string Email { get; set; } = string.Empty; } < /code> @{ var input = new InputModel { Id = "inputId", Label = "Email", Componente = ComponentEnum.Input, AspFor = "Contactos.Email", Value = Model.Contactos.Email }; }
@await Html.PartialAsync(ComponentEnum.Input.GetPath(), input) < /code> can someone help me understand how can i pass the AspFor dynamicaly and be able to create a generic InputModel when i create the Div directly in the page it works ok:
Ich versuche, eine Vorlage zu verwenden, die eine dynamische URL-Schaltfläche enthält, erhalte jedoch ständig die folgende Fehlermeldung:
{
error :{
message : (#131008) Required parameter is...
Ok, ich habe 3 Modelle: WorkoutViewModel hat eine Eins-zu-viele-Beziehung mit WorkoutExerciseViewModel, das eine Eins-zu-viele-Beziehung mit ExerciseSetViewModel hat. Ich benötige eine dynamische...