I'm developing a webapp using ASP.NET MVC and C#. I created my TextBox element using Html.Helper(string, object, object ). Now my problem is, is it possible to add a new html attribute in the already created TextBox element, like a javascript event element?
Because I'm having a trouble using onchange event. Please see the code below,
<% foreach(var md in MD){%>
<tr>
<td>
<div><%= Html.TextBox("tt"+md.id, md.id, new { onchange="changenow('dd"+md.id+"')"})%>
</div>
</td>
</tr>
<%}%>
My changenow javascript function will update the database using ajax implementation. Now everytime the I load my page, the changenow will execute, so an added overhead everytime my page load. So I assume that the changenow function will not execute when I create a textbox.
What should I do so that the changenow function will not execute when I load the page?
Please advise.
Many thanks.