-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9654e7c
commit 30d98e9
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
@using System.IO; | ||
@using System.Net; | ||
|
||
@page "/html" | ||
|
||
<h1>HTML</h1> | ||
|
||
<div class="container"> | ||
<div class="row"> | ||
<textarea id="decoded" class="form-control" rows="5" @bind="decoded"></textarea> | ||
</div> | ||
<div class="row"> | ||
<button id="btnEncode" name="btnEncode" class="btn btn-success float-right" | ||
@onclick="Encode"> | ||
Encode | ||
</button> | ||
</div> | ||
<div class="row"> | ||
<textarea id="encoded" class="form-control" rows="5" @bind="encoded"></textarea> | ||
</div> | ||
<div class="row"> | ||
<button id="btnDecode" name="btnDecode" class="btn btn-success float-right" | ||
@onclick="Decode"> | ||
Decode | ||
</button> | ||
</div> | ||
<div class="row"> | ||
<div>@((MarkupString)encoded)</div> | ||
</div> | ||
</div> | ||
|
||
@code { | ||
|
||
string decoded; | ||
string encoded; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
decoded = "<html><body><h1>Hello</h1></body></html>"; | ||
encoded = string.Empty; | ||
} | ||
|
||
private void Encode() | ||
{ | ||
var writer = new StringWriter(); | ||
WebUtility.HtmlDecode(decoded, writer); | ||
encoded = writer.ToString(); | ||
} | ||
|
||
private void Decode() | ||
{ | ||
decoded = WebUtility.HtmlEncode(encoded); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters