{"id":358,"date":"2019-02-06T23:46:44","date_gmt":"2019-02-07T03:46:44","guid":{"rendered":"https:\/\/benjaminray.com\/codebase\/?page_id=358"},"modified":"2024-08-10T22:15:33","modified_gmt":"2024-08-11T01:15:33","slug":"home","status":"publish","type":"page","link":"https:\/\/benjaminray.com\/codebase\/","title":{"rendered":"Home"},"content":{"rendered":"<div class=\"fusion-fullwidth fullwidth-box fusion-builder-row-1 fusion-flex-container has-pattern-background has-mask-background nonhundred-percent-fullwidth non-hundred-percent-height-scrolling\" style=\"--awb-border-radius-top-left:0px;--awb-border-radius-top-right:0px;--awb-border-radius-bottom-right:0px;--awb-border-radius-bottom-left:0px;--awb-flex-wrap:wrap;\" ><div class=\"fusion-builder-row fusion-row fusion-flex-align-items-flex-start fusion-flex-content-wrap\" style=\"max-width:1996.8px;margin-left: calc(-4% \/ 2 );margin-right: calc(-4% \/ 2 );\"><div class=\"fusion-layout-column fusion_builder_column fusion-builder-column-0 fusion_builder_column_1_1 1_1 fusion-flex-column\" style=\"--awb-bg-size:cover;--awb-width-large:100%;--awb-margin-top-large:0px;--awb-spacing-right-large:1.92%;--awb-margin-bottom-large:20px;--awb-spacing-left-large:1.92%;--awb-width-medium:100%;--awb-order-medium:0;--awb-spacing-right-medium:1.92%;--awb-spacing-left-medium:1.92%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;\"><div class=\"fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-flex-start fusion-content-layout-column\"><div class=\"fusion-text fusion-text-1\"><p>This is my repository for code samples. It is a means for me to document solutions to common problems so that I can reference them quickly when needed. Samples will be added to this site over time as I slowly migrate them from the thousands of text files that have served as my repository until now.<\/p>\n<p>Some code samples are complex, some are simple, some are correct, and some are incorrect. While I expect to be the only user of this site (I don't expect my samples to solve your code problems!), I don't see why this content shouldn't be available to others. Just be warned that these articles aren't being presented as \"the right way\" to do things.<\/p>\n<p>That being said, if you do happen to see glaring errors, or have suggestions that could improve some of the content, feel free to <a href=\"https:\/\/benjaminray.com\/codebase\/contact\/\">contact me<\/a>.<\/p>\n<\/div><div class=\"fusion-title title fusion-title-1 fusion-title-text fusion-title-size-three\"><div class=\"title-sep-container title-sep-container-left fusion-no-large-visibility fusion-no-medium-visibility fusion-no-small-visibility\"><div class=\"title-sep sep-single sep-solid\" style=\"border-color:#e0dede;\"><\/div><\/div><span class=\"awb-title-spacer fusion-no-large-visibility fusion-no-medium-visibility fusion-no-small-visibility\"><\/span><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:36;line-height:1.5;\">Recent Posts: All Categories<\/h3><span class=\"awb-title-spacer\"><\/span><div class=\"title-sep-container title-sep-container-right\"><div class=\"title-sep sep-single sep-solid\" style=\"border-color:#e0dede;\"><\/div><\/div><\/div><div class=\"fusion-recent-posts fusion-recent-posts-1 avada-container layout-default layout-columns-4 home-page-recent-posts\" style=\"--awb-margin-bottom:20px;\"><section class=\"fusion-columns columns fusion-columns-4 columns-4\"><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2025-09-05T09:42:54-03:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/smooth-font-size-scaling-between-two-viewport-widths\/\">Smooth Font Size Scaling Between Two Viewport Widths<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2025-09-05T09:42:54-03:00<\/span><span>September 5, 2025<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>It's common to want fluid scaling of a font size on medium screens where a page is facing reduced width but not enough to switch to the mobile layout. For example, if a page's mobile [...]<\/p><\/div><\/article><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2025-09-01T13:12:13-03:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/wordpress-add-css-js-to-plugin-theme-with-cache-busting-variable-passing\/\">WordPress &#8211; Add CSS\/JS to Plugin\/Theme (with cache-busting &#038; variable-passing)<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2025-09-01T13:12:13-03:00<\/span><span>August 29, 2025<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>This demonstrates how to add JavaScript and CSS files to the functions.php file for a WordPress plugin, theme, or child theme, with a few convenience features added in. Which Hooks to Use Use the following [...]<\/p><\/div><\/article><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2025-08-29T10:43:39-03:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/testing-updated-markdown-parser\/\">Testing Updated Markdown Parser<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2025-08-29T10:43:39-03:00<\/span><span>April 21, 2025<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>Simple code fence console.log('4'); Simple code fence within HTML tags ```js console.log('5'); ``` console.log('5'); Testing code blocks in HTML tags Testing Markdown inside a details\/summary block Hidden Code Sample ```js console.log('5'); ``` console.log('5'); \u00a0 Testing [...]<\/p><\/div><\/article><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2024-09-05T17:40:06-03:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/center-flexbox-column-between-two-variable-width-columns-common-toolbar-scenario\/\">Center Flexbox Column Between Two Variable-Width Columns (Common Toolbar Scenario)<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2024-09-05T17:40:06-03:00<\/span><span>September 5, 2024<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>The Issue I often run into the scenario where I'm building a toolbar with items on the left, in the middle, and on the right. The items on the left and right can often be [...]<\/p><\/div><\/article><\/section><\/div><div class=\"fusion-title title fusion-title-2 fusion-title-text fusion-title-size-three\"><div class=\"title-sep-container title-sep-container-left fusion-no-large-visibility fusion-no-medium-visibility fusion-no-small-visibility\"><div class=\"title-sep sep-single sep-solid\" style=\"border-color:#e0dede;\"><\/div><\/div><span class=\"awb-title-spacer fusion-no-large-visibility fusion-no-medium-visibility fusion-no-small-visibility\"><\/span><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:36;line-height:1.5;\">Recent Posts: React<\/h3><span class=\"awb-title-spacer\"><\/span><div class=\"title-sep-container title-sep-container-right\"><div class=\"title-sep sep-single sep-solid\" style=\"border-color:#e0dede;\"><\/div><\/div><\/div><div class=\"fusion-recent-posts fusion-recent-posts-2 avada-container layout-default layout-columns-4 home-page-recent-posts\" style=\"--awb-margin-bottom:20px;\"><section class=\"fusion-columns columns fusion-columns-4 columns-4\"><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2024-08-17T19:31:58-03:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/memoize-react-components-to-prevent-unnecessary-renders\/\">Memoize React Components to Prevent Unnecessary Renders<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2024-08-17T19:31:58-03:00<\/span><span>March 18, 2024<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>When the state of a React component changes, the component and all of its children will re-render. While this is fine for most cases, you may have a child component that does some heavy computation, [...]<\/p><\/div><\/article><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2024-08-17T23:35:40-03:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/styled-component-properties\/\">Styled Component Properties in React<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2024-08-17T23:35:40-03:00<\/span><span>March 15, 2024<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>By default, properties passed to a styled component are passed on as attributes to the native HTML element created. A regular property must be a valid HTML element attribute, or there will be an error [...]<\/p><\/div><\/article><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2024-03-18T19:38:09-03:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/updating-input-and-triggering-onchange-event-in-react\/\">Updating Input and Triggering onChange Event Programmatically in React<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2024-03-18T19:38:09-03:00<\/span><span>March 12, 2024<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>While it's easy to update an input's value using a ref, that doesn't trigger the input's onChange event, which may be an issue if you're relying on onChange to fire when the input value changes. [...]<\/p><\/div><\/article><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2024-03-18T13:28:22-03:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/ignore-first-render-in-reacts-useeffect\/\">Ignore First Render in React&#8217;s useEffect()<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2024-03-18T13:28:22-03:00<\/span><span>October 16, 2023<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>Sometimes you want to use useEffect() to catch a change in a state, but only after the initial value has been set. For example, you have a state called selectedId, and you want to do [...]<\/p><\/div><\/article><\/section><\/div><div class=\"fusion-title title fusion-title-3 fusion-title-text fusion-title-size-three\"><div class=\"title-sep-container title-sep-container-left fusion-no-large-visibility fusion-no-medium-visibility fusion-no-small-visibility\"><div class=\"title-sep sep-single sep-solid\" style=\"border-color:#e0dede;\"><\/div><\/div><span class=\"awb-title-spacer fusion-no-large-visibility fusion-no-medium-visibility fusion-no-small-visibility\"><\/span><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:36;line-height:1.5;\">Recent Posts: Entity Framework<\/h3><span class=\"awb-title-spacer\"><\/span><div class=\"title-sep-container title-sep-container-right\"><div class=\"title-sep sep-single sep-solid\" style=\"border-color:#e0dede;\"><\/div><\/div><\/div><div class=\"fusion-recent-posts fusion-recent-posts-3 avada-container layout-default layout-columns-4 home-page-recent-posts\" style=\"--awb-margin-bottom:20px;\"><section class=\"fusion-columns columns fusion-columns-4 columns-4\"><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2023-10-10T20:27:38-03:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/relationships-in-entity-framework-core-7\/\">Relationships in Entity Framework Core 7<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2023-10-10T20:27:38-03:00<\/span><span>October 10, 2023<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>One to Many Relationships This article does not yet include information about One-To-Many relationships in Entity Framework Core 7. However, One-To-Many relationships have not changed much since Entity Framework Core 3, so check out this [...]<\/p><\/div><\/article><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2021-02-18T10:26:22-04:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/working-as-a-team-with-migrations-in-entity-framework-core\/\">Working As a Team with Migrations in Entity Framework Core<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2021-02-18T10:26:22-04:00<\/span><span>February 17, 2021<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>The official Microsoft documentation for using Migrations in Team Environments covers the basics. However, they neglect to mention one very important thing: Removing Migrations in a Team Environment Can Be Deadly! Well, not deadly, but [...]<\/p><\/div><\/article><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2020-10-30T05:10:59-03:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/force-strings-to-use-varchar-in-entity-framework-core\/\">Force Strings to use VARCHAR in Entity Framework Core<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2020-10-30T05:10:59-03:00<\/span><span>October 29, 2020<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>The nvarchar data type requires twice as much space to store as an equivalent-length varchar. For that reason, it is usually recommended to use varchar when you don't have a requirement to store Unicode characters. [...]<\/p><\/div><\/article><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2020-10-28T01:41:27-03:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/seed-identity-data-in-asp-net-core\/\">Seed Identity Data in ASP.Net Core<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2020-10-28T01:41:27-03:00<\/span><span>October 28, 2020<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>When using Identity in ASP.Net Core, it can be useful to seed some data for testing purposes. How to go about that is not entirely obvious, given that the tables involved (IdentityRole, IdentityUser, IdentityUserRole) aren't [...]<\/p><\/div><\/article><\/section><\/div><div class=\"fusion-title title fusion-title-4 fusion-title-text fusion-title-size-three\"><div class=\"title-sep-container title-sep-container-left fusion-no-large-visibility fusion-no-medium-visibility fusion-no-small-visibility\"><div class=\"title-sep sep-single sep-solid\" style=\"border-color:#e0dede;\"><\/div><\/div><span class=\"awb-title-spacer fusion-no-large-visibility fusion-no-medium-visibility fusion-no-small-visibility\"><\/span><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:36;line-height:1.5;\">Recent Posts: jQuery<\/h3><span class=\"awb-title-spacer\"><\/span><div class=\"title-sep-container title-sep-container-right\"><div class=\"title-sep sep-single sep-solid\" style=\"border-color:#e0dede;\"><\/div><\/div><\/div><div class=\"fusion-recent-posts fusion-recent-posts-4 avada-container layout-default layout-columns-4 home-page-recent-posts\" style=\"--awb-margin-bottom:20px;\"><section class=\"fusion-columns columns fusion-columns-4 columns-4\"><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2019-02-11T22:30:07-04:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/check-if-element-has-id-using-jquery\/\">Check If Element Has ID Using jQuery<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2019-02-11T22:30:07-04:00<\/span><span>February 11, 2019<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>To check if an element has an ID: if ($(this).is('[id]') { \/\/ Has ID console.log('Has ID: ' + $(this).attr('id')); } else { \/\/ Has no ID console.log('Has no ID.'); }<\/p><\/div><\/article><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2019-02-06T23:56:27-04:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/jquery-selector-starts-ends-with\/\">jQuery &#8211; Selector Starts-Ends With<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2019-02-06T23:56:27-04:00<\/span><span>August 6, 2018<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>Selector Starts With: $('input[name^=somePrefix]').doSomething(); Selector ENDS with: $('input[name$=someSuffix]').doSomething(); In ASP.Net: This is particularly useful in ASP.Net when you may not want to specify clientidmode static, but still want to use jQuery to find the ID. [...]<\/p><\/div><\/article><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2019-02-06T23:56:45-04:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/bind-to-document-instead-of-elements-for-dynamic-elements\/\">jQuery &#8211; Bind to Document Instead of Elements for Dynamic Elements<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2019-02-06T23:56:45-04:00<\/span><span>August 6, 2018<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>When a DOM object is added after the DOM has loaded, the usual process of binding an event to a specific jQuery object may not be sufficient. E.g.: Normal binding to a button $(function() { [...]<\/p><\/div><\/article><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2019-02-06T23:57:31-04:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/jquery-get-ajax-post-error-details\/\">jQuery &#8211; Get Ajax Post Error Details<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2019-02-06T23:57:31-04:00<\/span><span>August 6, 2018<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>$.post('status.ajax.php', {deviceId: id}) .done( function(msg) { ... } ) .fail( function(xhr, textStatus, errorThrown) { alert(xhr.responseText); }); http:\/\/stackoverflow.com\/a\/12116790\/4669143<\/p><\/div><\/article><\/section><\/div><div class=\"fusion-title title fusion-title-5 fusion-title-text fusion-title-size-three\"><div class=\"title-sep-container title-sep-container-left fusion-no-large-visibility fusion-no-medium-visibility fusion-no-small-visibility\"><div class=\"title-sep sep-single sep-solid\" style=\"border-color:#e0dede;\"><\/div><\/div><span class=\"awb-title-spacer fusion-no-large-visibility fusion-no-medium-visibility fusion-no-small-visibility\"><\/span><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:36;line-height:1.5;\">Recent Posts: ASP.Net<\/h3><span class=\"awb-title-spacer\"><\/span><div class=\"title-sep-container title-sep-container-right\"><div class=\"title-sep sep-single sep-solid\" style=\"border-color:#e0dede;\"><\/div><\/div><\/div><div class=\"fusion-recent-posts fusion-recent-posts-5 avada-container layout-default layout-columns-4 home-page-recent-posts\" style=\"--awb-margin-bottom:20px;\"><section class=\"fusion-columns columns fusion-columns-4 columns-4\"><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2020-11-14T03:30:13-04:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/returning-status-codes-in-an-asp-net-mvc-core-controller\/\">Returning Status Codes in an ASP.Net MVC Core Controller<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2020-11-14T03:30:13-04:00<\/span><span>November 14, 2020<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>There are a few ways to return different status codes in an ASP.Net MVC Core controller. Simplified Helper Methods Some helper methods for the most common codes (there may be more than the list below): [...]<\/p><\/div><\/article><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2020-10-28T01:41:27-03:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/seed-identity-data-in-asp-net-core\/\">Seed Identity Data in ASP.Net Core<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2020-10-28T01:41:27-03:00<\/span><span>October 28, 2020<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>When using Identity in ASP.Net Core, it can be useful to seed some data for testing purposes. How to go about that is not entirely obvious, given that the tables involved (IdentityRole, IdentityUser, IdentityUserRole) aren't [...]<\/p><\/div><\/article><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2020-10-24T22:44:43-03:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/c-razor-syntax-quick-reference-link-only\/\">C# Razor Syntax Quick Reference (Link Only)<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2020-10-24T22:44:43-03:00<\/span><span>October 24, 2020<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>https:\/\/haacked.com\/archive\/2011\/01\/06\/razor-syntax-quick-reference.aspx\/<\/p><\/div><\/article><article class=\"post fusion-column column col col-lg-3 col-md-3 col-sm-3\"><div class=\"recent-posts-content\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2020-11-04T17:53:27-04:00<\/span><h4 class=\"entry-title\"><a href=\"https:\/\/benjaminray.com\/codebase\/entity-framework-core-model-in-net-framework-4x-project\/\">Entity Framework Core Model in .NET Framework 4x Project<\/a><\/h4><p class=\"meta\"><span class=\"vcard\" style=\"display: none;\"><span class=\"fn\"><a href=\"https:\/\/benjaminray.com\/codebase\/author\/cbadmin\/\" title=\"Posts by Ben\" rel=\"author\">Ben<\/a><\/span><\/span><span class=\"updated\" style=\"display:none;\">2020-11-04T17:53:27-04:00<\/span><span>October 23, 2020<\/span><span class=\"fusion-inline-sep\">|<\/span><\/p><p>Because .NET Standard is implemented by later versions of the .NET Framework and .NET Core, these two very different project types can actually play nicely together. (I think of .NET Standard like an interface implemented [...]<\/p><\/div><\/article><\/section><\/div><\/div><\/div><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"jetpack_post_was_ever_published":false,"footnotes":""},"class_list":["post-358","page","type-page","status-publish","hentry"],"acf":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/P9GNjN-5M","jetpack_likes_enabled":false,"_links":{"self":[{"href":"https:\/\/benjaminray.com\/codebase\/wp-json\/wp\/v2\/pages\/358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/benjaminray.com\/codebase\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/benjaminray.com\/codebase\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/benjaminray.com\/codebase\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/benjaminray.com\/codebase\/wp-json\/wp\/v2\/comments?post=358"}],"version-history":[{"count":61,"href":"https:\/\/benjaminray.com\/codebase\/wp-json\/wp\/v2\/pages\/358\/revisions"}],"predecessor-version":[{"id":2380,"href":"https:\/\/benjaminray.com\/codebase\/wp-json\/wp\/v2\/pages\/358\/revisions\/2380"}],"wp:attachment":[{"href":"https:\/\/benjaminray.com\/codebase\/wp-json\/wp\/v2\/media?parent=358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}