|
| 1 | +@{ |
| 2 | + ViewData["Title"] = "Home Page"; |
| 3 | +} |
| 4 | + |
| 5 | +<div id="index-page" class="jumbotron"> |
| 6 | + <div> |
| 7 | + <div>Action link navigation (shortcut is 'a')</div> |
| 8 | + @Html.ActionLink("Link to Table", "Table", "Home", null, new { data_shortcut = "a" }) |
| 9 | + </div> |
| 10 | + <div> |
| 11 | + <div>Navigation using javascript window.location</div> |
| 12 | + <input id="navigate-button" type="button" class="btn" value="Navigate to Table" /> |
| 13 | + </div> |
| 14 | + <div> |
| 15 | + <div>GET form with value for Home/Index</div> |
| 16 | + @using (Html.BeginForm("Table", "Home", FormMethod.Get)) |
| 17 | + { |
| 18 | + @Html.TextBox("getText", "GET") |
| 19 | + <input type="submit" value="Submit GET Form" /> |
| 20 | + } |
| 21 | + </div> |
| 22 | + <div> |
| 23 | + <div>POST form with value for Home/Index, but redirects to Home/About</div> |
| 24 | + @using (Html.BeginForm("Index", "Home", FormMethod.Post)) |
| 25 | + { |
| 26 | + @Html.TextBox("postText", "POST") |
| 27 | + <input type="submit" value="POST with Redirect" /> |
| 28 | + } |
| 29 | + </div> |
| 30 | + <div> |
| 31 | + <div>GET form for Home/About, submitting button value</div> |
| 32 | + @using (Html.BeginForm("Table", "Home", FormMethod.Get)) |
| 33 | + { |
| 34 | + <input type="submit" name="mySubmit" value="First" /> |
| 35 | + <input type="submit" name="mySubmit" value="Second" /> |
| 36 | + <input type="submit" value="Will not" /> |
| 37 | + } |
| 38 | + </div> |
| 39 | + <div> |
| 40 | + <div>Action link to page with explicit layout</div> |
| 41 | + @Html.ActionLink("Link to Contact", "Contact", "Home") |
| 42 | + </div> |
| 43 | + <div> |
| 44 | + <div>Event attached to page, appends extra button</div> |
| 45 | + <input id="clone-button" type="button" class="btn" value="Global click event" /> |
| 46 | + </div> |
| 47 | + <div> |
| 48 | + <div>Javascript state</div> |
| 49 | + Click counter: <input id="click-counter" type="text" /> |
| 50 | + Interval counter: <input id="interval-counter" type="text" /> |
| 51 | + </div> |
| 52 | +</div> |
| 53 | + |
| 54 | +@section scripts |
| 55 | + { |
| 56 | + <script> |
| 57 | + $(function() { |
| 58 | + $('#navigate-button').click(function () { |
| 59 | + window.navigate('@Url.Action("Table", "Home")'); |
| 60 | + }); |
| 61 | + $('body').on('click', '#clone-button', function() { |
| 62 | + $(this).after($(this).clone()); |
| 63 | + }); |
| 64 | +
|
| 65 | + $('#click-counter').val(clickCount); |
| 66 | + $('#index-page').click(function () { |
| 67 | + window.clickCount++; |
| 68 | + $('#click-counter').val(window.clickCount); |
| 69 | + }); |
| 70 | +
|
| 71 | + $('#interval-counter').val(window.times.length); |
| 72 | + setInterval(function () { |
| 73 | + var now = new Date(); |
| 74 | + while (window.times.length > 0) { |
| 75 | + var front = window.times[0]; |
| 76 | + if (now.getTime() - front.getTime() > 1000) { |
| 77 | + times.shift(); |
| 78 | + } else { |
| 79 | + break; |
| 80 | + } |
| 81 | + } |
| 82 | + times.push(now); |
| 83 | + $('#interval-counter').val(window.times.length); |
| 84 | + }, 1000); |
| 85 | + }) |
| 86 | + </script> |
| 87 | +} |
0 commit comments