Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

MVC GDPR without bootstrapper

$
0
0

I am trying to make a Document.cookie attach to a <button> click, making the GDPR dissapear via document.cookie. 

how do i avoid the limits of "function()"?

Cant make Write(cookieString) and document.getElementById('cookieConsent').style.display = 'none'; both work at the same time, nomatter what combination i use.</div> <div></div> <div>Do i need to use "<html> datasets" or what do i do?</div> <div></div> <div>

@using Microsoft.AspNetCore.Http.Features
@{
    var consentFeature = Context.Features.Get<ITrackingConsentFeature>();
    var showBanner = !consentFeature?.CanTrack ?? false;
    var cookieString = consentFeature?.CreateConsentCookie();
}
@if (showBanner)
{
    @*data-target="#cookieConsent"*@<nav id="cookieConsent" class="navbar" role="alert"><div><p>No cookies are currently tracking.</p><a asp-controller="Home" asp-action="Privacy">Learn More</a><button type="button" id="mybutton" onclick="cookieaccept(); cookieaccept2();" data-cookie="cookiestring">Accept</button></div></nav><script>
    //Write(cookieString);
    //document.getElementById('cookieConsent').style.display = 'none';
    //document.cookie = dataset.cookieString;
    //document.querySelector(""#cookieConsent button[data-cookie]"").addEventListener(""click"", function (el){ 
        function cookieaccept() {
            document.getElementById('cookieConsent').style.display = 'none';
        }
        function cookieaccept2() {
            Write(cookieString);
        }</script>
}

Viewing all articles
Browse latest Browse all 9386

Trending Articles