Convert PHP to ASP.NET MVC

I have PHP code like this

<div class="row">
        <?php
          $sqldata = sqlsrv_query($conn,"select max(id) as id from cnp_loker");
          $data = sqlsrv_fetch_array($sqldata);
          if($data){
            $value= substr($data[0],1);
            $id = (int) $value;
            $id = $id + 1;
            $hasilkode = "RN".str_pad($id, 6, "0",STR_PAD_LEFT);
          }else{
            $hasilkode = "RN000000";
          }
        ?>
      <form method="POST" class="form-horizontal form-label-left" action="addnew.php">

and I want to convert it to ASP.NET MVC C# program language how to type the code?