Please refer below code, I have implemented in aspx engine and do the same using razor engine
Index(View)
<div>
<% using (Html.BeginForm())
{ %>
<%: Html.TextBox("txtValue") %>
<br />
<div id="div1" class="divs">
**div1**
</div>
<div id="div2" class="divs">
**div2**
</div>
<% } %>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$('.divs').hide();
$('[id*=txtValue]').on('keyup', function () {
$('.divs').hide();
$('#div' + $(this).val()).show();
});
});
</script>
Screenshot