Click here to Skip to main content
15,904,817 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i have a textbox GLGroupCode after entering a text into this i ineed to execute a action method which takes this as text as a prameter



@Html.LabelFor(model => model.GLGroupCode)


@Html.TextBoxFor(model => model.GLGroupCode)
@Html.ValidationMessageFor(model => model.GLGroupCode)


@Html.LabelFor(model => model.GLGroupName)


@Html.TextBoxFor(model => model.GLGroupName)
@Html.ValidationMessageFor(model => model.GLGroupName)
Posted
Comments
F-ES Sitecore 12-Nov-15 10:15am    
google "jquery input change event", "jquery call mvc action" and put the two together.

1 solution

You can do this using ajax call like below

Index



@Html.LabelFor(model => model.GroupCode)

@Html.TextBoxFor(model => model.GroupCode)
@Html.ValidationMessageFor(model => model.GroupCode)

@Html.LabelFor(model => model.GroupName)

@Html.TextBoxFor(model => model.GroupName)
@Html.ValidationMessageFor(model => model.GroupName)


<script src="~/Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$('#GroupCode').on('change',function(event){
$.ajax({
url: "/Dept/TextChanged",
type: "GET",
data: { text : $('#GroupCode').val() },
dataType: 'json',
success: function(result){
$('#GroupName').val(result);
}
});
});
</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900