17 Feb 20226 minutes to read
This section briefly explains about how to render Tooltip component in your ASP.NET MVC application. You can referASP.NET MVC Getting Started documentation page for introduction part of the system requirements and configure the common specifications.
Starting with
v16.2.0.x
, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, you also have to include a license key in your projects. Please refer to thislink to know about registering Syncfusion license key in your ASP .NET MVC application to use our components.
Tooltip component can be rendered with the help of@Html.EJS().Tooltip
tag helper. Add the below code to yourindex.cshtml
page which is present underViews/Home
folder, where the Tooltip is initialized.
@Html.EJS().Tooltip("Tooltip").Content("Lets go green & Save Earth !!!").ContentTemplate(@<spanid='target'>ShowTooltip</span>).Render()
After successful compilation of your application, simply pressF5
to run the application.
The following example shows a basic Tooltip.
@using Syncfusion.EJ2@using Syncfusion.EJ2.Popups@Html.EJS().Tooltip("Tooltip").Content("Lets go green& Save Earth !!!").ContentTemplate(@<spanid='target'>Show Tooltip</span>).Render()
publicIActionResultIndex(){returnView();}
In the above sample code,
#target
is theid
of the element in a page to which theTooltip
is initialized.
Output be like the below.
You can create Tooltips on multiple targets within a container. To do so, you have to define specific target elements to thetarget
property so that the Tooltip is initialized only on matched targets within a container. In this case, the Tooltip content is assigned from thetitle
attribute of the target element.
Refer to the following code example to create a Tooltip on multiple targets within a container.
@using Syncfusion.EJ2@using Syncfusion.EJ2.Popups@Html.EJS().Tooltip("Tooltip").Target(".e-info").Position(Syncfusion.EJ2.Popups.Position.RightCenter).ContentTemplate(@<formid="details"role="form"><table><tr><tdclass="info"> User Name:</td><td><inputtype="text"class="e-info"name="firstname"title="Please enter your name"></td></tr><tr><tdclass="info"> Email Address:</td><td><inputtype="text"class="e-info"name="email"title="Enter a valid email address"></td></tr><tr><tdclass="info"> Password:</td><td><inputtype="password"class="e-info"name="password"title="Be at least 8 characters length"></td></tr><tr><tdclass="info"> Confirm Password:</td><td><inputtype="password"class="e-info"name="Cpwd"title="Re-enter your password"></td></tr></table><inputid="sample"type="submit"value="Submit"><inputid="clear"type="reset"value="Reset"></form>).Render()<style> #container { visibility: hidden; } #loader { color: #008cff; height: 40px; left: 45%; position: absolute; top: 45%; width: 30%; } #details table th, #details table td { padding: 15px; text-align: left; } #details .info { font-weight: bold; }</style>
publicIActionResultIndex(){returnView();}
Output be like the below.
In the above sample,
#details
refers to the container’s id, and the target.e-info
refers to the target elements available within that container.