Search code examples
javascriptasp.net-mvcrazorrazorengine

How to call ONLY javascript function in html.actionlink


I have java script function

   function SetTextBoxValue(data) {
        $('#text_box').val($(this).val("myField"))

    };

Is it possible, and how, to call only this function, WITHOUT controller and action names from @Html.ActionLink() in razor view?

To extend a question, i have table and a form with 4 text boxes on same view. I need to fill one textbox with a value of a specific column in table when user click on link in that column.


Solution

  • try this :

    @Html.ActionLink("LinkText", "#", "", null, new { onclick="SetTextBoxValue('mydata')" });
    

    Hope this helps.