Hi rani,
Using the article i have created the example.
Check this example. Now please take its reference and correct your code.
Model
using System.ComponentModel.DataAnnotations;
public class UserModel
{
[Display(Name = "First Name:")]
public string FirstName { get; set; }
[Display(Name = "Last Name:")]
public string LastName { get; set; }
}
Controller
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
}
View
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@model Watermark_TextBox_Core_MVC.Models.UserModel
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="~/Scripts/WaterMark.min.js"></script>
<script type="text/javascript">
$(function () {
//Default usage.
$("#FirstName").WaterMark();
//Change color of Watermark.
$("#LastName").WaterMark({
WaterMarkTextColor: '#ff0000'
});
});
</script>
</head>
<body>
<form asp-action="Index">
<table>
<tr>
<td><label asp-for="FirstName"></label></td>
<td><input asp-for="FirstName" title="Enter First Name" /></td>
</tr>
<tr>
<td><label asp-for="LastName"></label></td>
<td><input asp-for="LastName" title="Enter Last Name" /></td>
</tr>
</table>
</form>
</body>
</html>
Screenshot