Skip to content

Instantly share code, notes, and snippets.

View scottaddie's full-sized avatar
💭
.NET 💜 Azure

Scott Addie scottaddie

💭
.NET 💜 Azure
View GitHub Profile
@scottaddie
scottaddie / _ViewImports.cshtml
Created March 3, 2018 19:32
Using the addTagHelper directive to register the LinkButtonTagHelper
@addTagHelper *, TagHelperSuite
@scottaddie
scottaddie / Index.cshtml
Created March 3, 2018 16:51
LinkButtonTagHelper markup in ASP.NET Core
<form asp-page-handler="Post">
<link-button>Test Link</link-button>
</form>
@scottaddie
scottaddie / Default.aspx
Created March 3, 2018 16:49
Web Forms LinkButton sample in Default.aspx
<asp:LinkButton ID="lbtnSubmit" runat="server" PostBackUrl="~/About.aspx" Text="Submit Form" />
@scottaddie
scottaddie / Index.cshtml
Created March 3, 2018 16:47
Index Razor Page CSHTML file in an ASP.NET Core 2.x app
<form method="post">
<button asp-page="/Index" asp-page-handler="Post">Submit Form</button>
</form>
@scottaddie
scottaddie / Index.cshtml.cs
Created March 3, 2018 16:46
Index page model in an ASP.NET Core 2.x Razor Pages app
public class IndexModel : PageModel
{
public void OnGet()
{
}
public void OnPost()
{
}
}
@scottaddie
scottaddie / LinkButtonTagHelper.cs
Created March 3, 2018 16:33
Custom Tag Helper for rendering a LinkButton-like anchor in ASP.NET Core
[HtmlTargetElement("link-button")]
public class LinkButtonTagHelper : TagHelper
{
public override void Process(TagHelperContext context, TagHelperOutput output)
{
const string HIDDEN_FIELD_ID = "form_marker";
output.TagName = "a";
output.Attributes.SetAttribute("onclick",
$@"document.getElementById(""{HIDDEN_FIELD_ID}"").form.submit();");
@scottaddie
scottaddie / hosting.json
Created December 14, 2015 04:09
hosting.json file to configure webroot folder
{
"webroot": "build"
}
@scottaddie
scottaddie / WebpackHelper.cs
Last active June 29, 2017 15:51
C# helper method to parse webpack.assets.json
public static JObject GetWebpackAssetsJson(string applicationBasePath)
{
JObject webpackAssetsJson = null;
string packageJsonFilePath = $"{applicationBasePath}\\{"package.json"}";
using (StreamReader packageJsonFile = File.OpenText(packageJsonFilePath))
{
using (JsonTextReader packageJsonReader = new JsonTextReader(packageJsonFile))
{
JObject packageJson = (JObject)JToken.ReadFrom(packageJsonReader);
@scottaddie
scottaddie / tasks.json
Last active May 19, 2017 07:56
Webpack integration via tasks.json
{
"version": "0.1.0",
"command": "${workspaceRoot}/node_modules/.bin/webpack",
"isShellCommand": true,
"args": [
"--display-modules",
"--progress"
],
"echoCommand": true,
"tasks": [
@scottaddie
scottaddie / Index.cshtml
Last active January 31, 2017 03:44
Custom tag helpers being used in an ASP.NET Core MVC Razor view
@using static TagHelpersDemo.TagHelpers.CardTagHelper
@{
ViewData["Title"] = "Home Page";
}
<div class="clearfix">&nbsp;</div>
<hand player="John">
<card suit="@CardSuit.Heart" rank="@CardRank.Ace"></card>