2

Im trying to complete this very simple task using razor engine (c#+html). Im editing the cshtml file of this view and essentially im trying to achieve this exact code but in "razor" format. Here is what im trying to achieve but in javascript:

HTML:

<p>How many check boxes do you want when clicked on a radio button?</p>
<input type="radio" name="tab" value="igotnone" onclick="show1();" />
None
<input type="radio" name="tab" value="igottwo" onclick="show2();" />
Two
<div id="div1" class="hide">
  <hr><p>Okay Cool! Here are those two...</p>
<input type="checkbox" value="Yes" name="one">
One &nbsp;
<input type="checkbox" value="Yes" name="two">
Two
</div>

JAVASCRIPT:

function show1(){
  document.getElementById('div1').style.display ='none';
}
function show2(){
  document.getElementById('div1').style.display = 'block';
}

What is the code for achieving this exact effect but in cshtml/whatever else is necessary in razor engine?

Total newb when it comes to this front end stuff so I have a second follow up question. I am led to believe that this function needs to go elsewhere like in the "controller" files. Is that necessary or can I insert this method into my cshtml file? Because currently I am editing the already published website through Microsoft Azure's "App preview editor" and it doesn't seem that I can get access to the solution with those files (unless there is o.o)

Thanks!

Babosura
  • 21
  • 3
  • 2
    Razor is server side code. Javascript is client side code. If you want to handle client side events then you need javascript (as you already have) –  Jan 15 '18 at 23:18
  • I guess the next question is then where would this go in my directory to have the page execute the above code? NVM Got it THANKS!!!! – Babosura Jan 15 '18 at 23:32

0 Answers0