Remove text onclick/onfocus event of @Html.TextArea
11,696
Solution 1
TextBox
@Html.TextBox("ControlName",
"Some Value",
new { onclick = "alert('Razor Engine')" });
@Html.TextBoxFor(m => m.Value, new
{
onclick = "alert('Razor Engine')",
@Value = "Some Value"
});
TextArea
@Html.TextArea("ControlName",
"Some Value",
new { onclick = "alert('Razor Engine')" });
@Html.TextAreaFor(m => m.Value, new
{
onclick = "alert('Razor Engine')"
});
Solution 2
Try something like below.
<%= Html.TextBox("obpt9",ViewData.Eval("obpt9"), new { onclick = "alert('hi')" })%>
You can find more information from below link. Add OnClick Event to Html.RadioButton
Related videos on Youtube
Author by
haldar55
Working currently in Infosys Ltd. as a Senior Systems Engineer
Updated on June 04, 2022Comments
-
haldar55 almost 2 years
I am working on an MVC 3 project. In my view I have textboxes and Text area which I am calling using @Html.TextBox/TextArea.
Can anyone please tell me, how can I define the onclick or onfocus even of these controls? I am unable to find a syntax for this.
-
haldar55 almost 11 yearsI am using Razor engine for my view.
-
-
Jalpesh Vadgama almost 11 yearsuse @ instead of <%= that is simple