I carefully read it and realized what you want to do. However, your example is something that is misleading. (it seems everyone answered)
What you did in the second example should work fine, you can wrap your jQuery in a <text></text> element if that helps. If only one value you could just
<script type='text/javascript'> @{ var x = ((SelectList)ViewData["Gruplar"]).First(); } $("#GroupC_grup_name").attr('value', '@x.Text'); $("#GroupC_id").attr('value', '@x.Value'); </script>
There are several ways you could execute a razor in jquery. This is basically the same as an html razor.
That you want to perform a razor on the client side, then it does not happen. Razor is executed before it is sent to the client.
Buildstarted
source share