0% found this document useful (0 votes)
2 views7 pages

Create CSHTML

The document provides an overview of HTML Tag Helpers in ASP.NET, detailing the usage of hyperlinks, input types, and select elements. It also covers model validation attributes such as DataType, Required, Range, StringLength, and Compare. Additionally, it includes an example of a form for file uploads with a custom file input control.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

Create CSHTML

The document provides an overview of HTML Tag Helpers in ASP.NET, detailing the usage of hyperlinks, input types, and select elements. It also covers model validation attributes such as DataType, Required, Range, StringLength, and Compare. Additionally, it includes an example of a form for file uploads with a custom file input control.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Create.

cshtml
Html Code
1- Html Tag Helper
• Hyperlink
• <a href="/Speaker/Detail/12">SpeakerId: 12</a>
• <a asp-controller="Speaker" asp-action="Detail" asp-route-id=“12">SpeakerId: 12</a>
• Input
• <input asp-for=“property" class="form-control" />
• Text : Property is String
• Number : Property is numeric
• Date : Data type of property is Date
• Time : : Data type of property is Time
• Password: Data type of property is password
• Checked : property is boolean
1- Html Tag Helper
• <input type="radio" asp-for="Property" value="Male" Checked /> Male
• <input type="Checkbox" asp-for="Property" value="1" Checked /> Active
• Select
• Controller (HttpGet Create() )
• ViewBag.country = new List<string> { "Jordan" , "Syria" , "Palestine" };
• Html
• <select asp-for="Country" class="form-select" asp-items="new
SelectList(ViewBag.country)" ></select>
2- Model Validation
• Data Type
• [DataType(DataType.EmailAddress)]
• [DataType(DataType.Date)]
• [DataType(DataType.Password)]
• Etc

• Required
• [Required(ErrorMessage =“Message")]

• Range
• [Range(min, max, ErrorMessage =“Message")]
2- Model Validation
• StringLength
• [StringLength(max)]
• [StringLength(max,MinimumLength =min,ErrorMessage ="")]

• Compare
• [Compare(“Property",ErrorMessage ="")]
Programming Create (HTML)
• Form
• <form enctype="multipart/form-data" asp-action="New">

• Control
• <div class="custom-file">
<input asp-for="ProfileImage" class="custom-file-input" id="customFile">
<label class="custom-file-label" for="customFile">Choose file</label>
</div>

You might also like