Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question
    
The script does not make sense (what is $(this) in the context of the function?). Show the html and indicate what your trying to do. –  Stephen Muecke Oct 27 '14 at 1:44
    
$(this) is @html.actionlink defined as " @Html.ActionLink(modelItem.myfield, "controller", "action" new { OnClick = "SetTextBoxValue()" })" –  onedevteam.com Oct 27 '14 at 1:48
    
No its not.$(this) would be Window. I think your going about this the wrong way. Post some html so it clearer what your trying to do. –  Stephen Muecke Oct 27 '14 at 1:58
    
Why use Html.Actionlink if you only need js code to execute? –  David Tansey Oct 27 '14 at 2:19

1 Answer 1

up vote 1 down vote accepted

try this :

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

Hope this helps.

share|improve this answer
    
Actually, you have to do it as onclick="return SetTextBoxValue('mydate')" –  Dean.DePue May 8 at 10:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.