Exception in template (Forms/Form\BleauBorger_Formular_WCAGmodul.cshtml): System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.becfdbabbcaf.Execute() at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context) at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag) at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName) at RazorEngine.Razor.Parse[T](String razorTemplate, T model, DynamicViewBag viewBag, String cacheName) at Dynamicweb.Rendering.Template.RenderRazorTemplate()
@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using Dynamicweb.Configuration @using Dynamicweb.Rendering @using Dynamicweb @using Dynamicweb.Modules @using System.Web @using Dynamicweb.Content.Items @{ string designName = Pageview.Layout.Design.Name; string RefUrl = System.Web.HttpContext.Current.Request.UrlReferrer.ToString(); String FormName = @GetString("Form.Name"); } <script src="/Files/Templates/Designs/@designName/assets/javascripts/bootstrapValidator.js"></script> <script src="/Files/Templates/Designs/@designName/assets/javascripts/countrycode_DA_DK.js"></script> <link rel="stylesheet" href="/Files/Templates/Designs/@designName/assets/stylesheets/bootstrapValidator.css" /> <link rel="stylesheet" href="/Files/Templates/Designs/@designName/assets/stylesheets/BleauBorger_Formular.min.css" /> @GetValue("Form.FormStart") @GetValue("Form.SystemFields") @{ string formID = "#" + @GetString("Form.HtmlId"); } <script> $(document).ready(function() { $('@formID') .bootstrapValidator({ excluded: [':disabled', ':hidden', ':not(:visible)'], feedbackIcons: { valid: 'glyphicon glyphicon-ok', invalid: 'glyphicon glyphicon-remove', validating: 'glyphicon glyphicon-refresh' } }) .on('status.field.bv', function (e, data) { //enable submit button at all times data.bv.disableSubmitButtons(false); }) .on('success.form.bv', function(e) { // Reset the message element when the form is valid $('#errors').html(''); }) //Links to validation error fields at the bottom .on('error.field.bv', function(e, data) { // data.bv --> The BootstrapValidator instance // data.field --> The field name // data.element --> The field element // Get the messages of field var messages = data.bv.getMessages(data.element); // Remove the field messages if they're already available $('#errors').find('li[data-field="' + data.field + '"]').remove(); // Loop over the messages for (var i in messages) { // Create new 'li' element to show the message $('<li/>') .attr('data-field', data.field) .wrapInner( $('<a/>') .attr('href', 'javascript: void(0);') .html(messages[i]) .on('click', function(e) { // Focus on the invalid field data.element.focus(); }) ) .appendTo('#errors'); //show errors and headline $("#errordiv").attr("style", "display: block !important;") } // Hide the default message // $field.data('bv.messages') returns the default element containing the messages //data.element //.data('bv.messages') // .find('.help-block[data-bv-for="' + data.field + '"]') // .hide(); }) .on('success.field.bv', function(e, data) { // Remove the field messages $('#errors').find('li[data-field="' + data.field + '"]').remove(); if($("#errors li").length == 0){$('#errordiv').hide('');} }); }); </script> @foreach (LoopItem field in GetLoop("Fields")) { string required = field.GetBoolean("Field.Required") ? "required" : ""; string ariareq = field.GetBoolean("Field.Required") ? "true" : "false"; string isRequired = field.GetBoolean("Field.Required") ? "true" : "false"; string ariaDescribedby = ""; /*---------- Checkboks felt ----------*/ if (field.GetString("Field.Type") == "CheckBox") { <div class="form-group has-feedback @required"> <label for="@field.GetValue("Field.SystemName")" id="@field.GetValue("Field.SystemName")group" class="control-label">@field.GetValue("Field.Name")</label> @if (!string.IsNullOrEmpty(Convert.ToString(@field.GetValue("Field.Description")))) {<div id="@field.GetValue("Field.SystemName")Desc" class="show">@field.GetValue("Field.Description")</div>} <div class="checkbox"> <label for="@field.GetValue("Field.SystemName")" id="@field.GetValue("Field.SystemName")label" class="col-form-label control-label"> <input type="@field.GetValue("Field.Type")" class="form-check-input" name="@field.GetString("Field.SystemName")" id="@field.GetValue("Field.SystemName")" @required data-bv-choice="@isRequired" data-bv-choice-min="1" data-bv-choice-message='Sæt kryds i "@Translate(@field.GetString("Field.Name"))"' data-bv-trigger="click blur keyup" /> @Translate(@field.GetString("Field.Name")) </label> </div> </div> } /*---------- Checkbox liste felt ----------*/ else if (field.GetString("Field.Type") == "CheckBoxList") { <div role="group" id="@field.GetValue("Field.SystemName")Group" aria-labelledby="@field.GetValue("Field.SystemName")" class="form-group has-feedback @required"> <label for="@field.GetValue("Field.SystemName")" id="@field.GetValue("Field.SystemName")" class="col-form-label control-label">@field.GetValue("Field.Name")</label> @if (!string.IsNullOrEmpty(Convert.ToString(@field.GetValue("Field.Description")))) {<div id="@field.GetValue("Field.SystemName")Desc" class="show">@field.GetValue("Field.Description")</div>} @foreach (LoopItem option in field.GetLoop("Options")) { <div class="checkbox"> <label for="@option.GetValue("Option.ID")"> @if (option.GetString("Option.Sort") == "1") { <input type="checkbox" class="form-check-input" name="@field.GetString("Field.SystemName")" value="@option.GetValue("Option.Value")" id="@option.GetValue("Option.ID")" data-bv-choice="@isRequired" data-bv-choice-min="1" data-bv-choice-message='Sæt kryds i "@Translate(@field.GetString("Field.Name"))"' data-bv-trigger="click blur keyup" /> } else { <input type="checkbox" name="@field.GetString("Field.SystemName")" value="@option.GetValue("Option.Value")" id="@option.GetValue("Option.ID")" /> } @option.GetValue("Option.Text") </label> </div> } </div> } /*---------- Radio buttons felt ----------*/ else if (field.GetString("Field.Type") == "Radio") { <div role="radiogroup" id="@field.GetValue("Field.SystemName")" aria-labelledby="@field.GetValue("Field.SystemName")label" class="form-group has-feedback @required"> <label for="@field.GetValue("Field.SystemName")" id="@field.GetValue("Field.SystemName")label" class="control-label">@field.GetValue("Field.Name")</label> @if (!string.IsNullOrEmpty(Convert.ToString(@field.GetValue("Field.Description")))) {<div id="@field.GetValue("Field.SystemName")Desc" class="show">@field.GetValue("Field.Description")</div>} @foreach (LoopItem option in field.GetLoop("Options")) { <div class="radio"> <label for="@field.GetValue("Field.SystemName")@option.GetValue("Option.ID")"> @if (option.GetString("Option.Sort") == "1") { <input type="radio" id="@field.GetValue("Field.SystemName")@option.GetValue("Option.ID")" name="@field.GetValue("Field.SystemName")" value="@option.GetValue("Option.Value")" data-bv-choice="@isRequired" data-bv-choice-min="1" data-bv-choice-message='Du har ikke udfyldt "@Translate(@field.GetString("Field.Name"))"' data-bv-trigger="click blur keyup" /> } else { <input type="radio" id="@field.GetValue("Field.SystemName")@option.GetValue("Option.ID")" name="@field.GetValue("Field.SystemName")" value="@option.GetValue("Option.Value")" /> } @option.GetValue("Option.Text") </label> </div> } </div> } /*---------- Color felt ----------*/ else if (field.GetString("Field.Type") == "color") { <div class="form-group has-feedback @required"> <label for="@field.GetValue("Field.SystemName")" id="@field.GetValue("Field.SystemName")label" class="col-form-label control-label">@Translate(@field.GetString("Field.Name"))</label> @if (!string.IsNullOrEmpty(Convert.ToString(@field.GetValue("Field.Description")))) { <div id="@field.GetValue("Field.SystemName")Desc" class="show">@field.GetValue("Field.Description")</div> } <textarea class="form-control" name="@field.GetString("Field.SystemName")" id="@field.GetValue("Field.SystemName")" value="@field.GetString("Field.Value")" placeholder="@field.GetString("Field.Placeholder")" data-error="" aria-labelledby="@field.GetValue("Field.SystemName")label" aria-describedby="@field.GetValue("Field.SystemName")Desc" data-bv-hexcolor="@isRequired" data-bv-notempty-message='Udfyld venligst feltet "@Translate(@field.GetString("Field.Name"))"' data-bv-hexcolor-message="Farvekoden er ikke gyldig" data-bv-trigger="blur keyup"></textarea> </div> } /*---------- Email felt ----------*/ else if (field.GetString("Field.Type") == "Email") { <div class="form-group has-feedback @required"> <label for="@field.GetValue("Field.SystemName")" id="@field.GetValue("Field.SystemName")label" class="col-form-label control-label">@Translate(@field.GetString("Field.Name"))</label> @if (!string.IsNullOrEmpty(Convert.ToString(@field.GetValue("Field.Description")))) {<div id="@field.GetValue("Field.SystemName")Desc">@field.GetValue("Field.Description")</div>} <input type="email" class="form-control" name="@field.GetString("Field.SystemName")" id="@field.GetValue("Field.SystemName")" placeholder="@field.GetString("Field.Placeholder")" aria-labelledby="@field.GetValue("Field.SystemName")label" aria-describedby="@field.GetValue("Field.SystemName")Desc" @required data-bv-emailaddress="@isRequired" data-bv-notempty-message='Udfyld venligst feltet "@Translate(@field.GetString("Field.Name"))"' data-bv-emailaddress-message="E-mailaddressen er ugyldig" data-bv-trigger="blur keyup" /> </div> } /*---------- Range felt ----------*/ else if (field.GetString("Field.Type") == "Range") { <div class="form-group has-feedback"> <label for="@field.GetValue("Field.SystemName")" id="@field.GetValue("Field.SystemName")label" class="col-form-label control-label">@Translate(@field.GetString("Field.Name"))</label> @if (!string.IsNullOrEmpty(Convert.ToString(@field.GetValue("Field.Description")))) {<div id="@field.GetValue("Field.SystemName")Desc">@field.GetValue("Field.Description") (@Translate("Value", "nuværende værdi"): <span id="demo"></span>)</div>} <input type="range" class="slider form-control" name="@field.GetString("Field.SystemName")" id="@field.GetValue("Field.SystemName")" placeholder="@field.GetString("Field.Placeholder")" aria-labelledby="@field.GetValue("Field.SystemName")label" aria-describedby="@field.GetValue("Field.SystemName")Desc" data-bv-between="@isRequired" max="@field.GetValue("Field.MaxLength")" min="0" data-bv-between-message="Værdien skal være mellem 0 og @field.GetValue("Field.MaxLength")" /> <script> var slider = document.getElementById("@field.GetValue("Field.SystemName")"); var output = document.getElementById("demo"); output.innerHTML = slider.value; slider.oninput = function() { output.innerHTML = this.value; } </script> </div> } /*---------- Notat felt ----------*/ else if (field.GetString("Field.Type") == "Textarea") { <div class="form-group has-feedback @required"> <label for="@field.GetValue("Field.SystemName")" id="@field.GetValue("Field.SystemName")label" class="col-form-label control-label">@Translate(@field.GetString("Field.Name"))</label> @if (!string.IsNullOrEmpty(Convert.ToString(@field.GetValue("Field.Description")))) {<div id="@field.GetValue("Field.SystemName")Desc" class="show">@field.GetValue("Field.Description")</div>} <textarea class="form-control" name="@field.GetString("Field.SystemName")" id="@field.GetValue("Field.SystemName")" value="@field.GetString("Field.Value")" placeholder="@field.GetString("Field.Placeholder")" data-error="" aria-labelledby="@field.GetValue("Field.SystemName")label" aria-describedby="@field.GetValue("Field.SystemName")Desc" @required data-bv-notempty-message='Udfyld venligst feltet "@Translate(@field.GetString("Field.Name"))"' data-bv-trigger="blur keyup"></textarea> </div> } /*---------- URL felt ----------*/ else if (field.GetString("Field.Type") == "Url") { <div class="form-group @required"> <label for="@field.GetValue("Field.SystemName")" id="@field.GetValue("Field.SystemName")label" class="col-form-label control-label">@Translate(@field.GetString("Field.Name"))</label> @if (!string.IsNullOrEmpty(Convert.ToString(@field.GetValue("Field.Description")))) {<div id="@field.GetValue("Field.SystemName")Desc">@field.GetValue("Field.Description")</div>} <input class="form-control" name="@field.GetString("Field.SystemName")" id="@field.GetValue("Field.SystemName")" type="url" value="@field.GetString("Field.Value")" placeholder="@field.GetString("Field.Placeholder")" data-error="" aria-labelledby="@field.GetValue("Field.SystemName")label" aria-describedby="@field.GetValue("Field.SystemName")Desc" @required data-bv-uri="@isRequired" data-bv-notempty-message='Udfyld venligst feltet "@Translate(@field.GetString("Field.Name"))"' data-bv-uri-message="Webadressen er ikke gyldig. Har du husket http:// eller https://?" data-bv-trigger="blur keyup" /> </div> } /*---------- Tilføj-filer felt ----------*/ else if (field.GetString("Field.Type") == "File") { <div class="form-group @required"> <label for="@field.GetValue("Field.SystemName")@field.GetValue("Form.ID")" class="control-label">@Translate(@field.GetString("Field.Name"))</label> @if (!string.IsNullOrEmpty(Convert.ToString(@field.GetValue("Field.Description")))) {<div id="@field.GetValue("Field.SystemName")Desc">@field.GetValue("Field.Description")</div>} <input type="file" class="form-control" name="@field.GetString("Field.SystemName")" id="@field.GetValue("Field.SystemName")@field.GetValue("Form.ID")" multiple @required data-bv-file="@isRequired" data-bv-file-extension="jpeg,jpg,png,pdf,txt,doc,zip,rar,ppt,rtf,m4a,mp3,mp4,m4v,mov,xls,xlsx,html" data-bv-file-message="Filtypen er ikke tilladt. Tilladte filtyper er jpeg, jpg, png, pdf, txt, doc, zip, rar, ppt, rtf, m4a, mp3, mp4, m4v, mov, xls, xlsx og html)" data-bv-notempty-message='Udfyld venligst feltet "@Translate(@field.GetString("Field.Name"))"' data-bv-trigger="blur keyup" /> </div> } /*---------- Selectboks ----------*/ else if (field.GetString("Field.Type") == "Select") { <div class="form-group @required"> <label for="@field.GetValue("Field.SystemName")" id="@field.GetValue("Field.SystemName")label" class="col-form-label control-label">@Translate(@field.GetString("Field.Name"))</label> @if (!string.IsNullOrEmpty(Convert.ToString(@field.GetValue("Field.Description")))) {<div id="@field.GetValue("Field.SystemName")Desc" class="show">@field.GetValue("Field.Description")</div>} <div>@field.GetString("Field.Control").Replace(" id", " data-bv-trigger = \"blur keyup\" class=\"form-control\" id")</div> </div> } /*---------- Password felt ----------*/ else if (field.GetString("Field.Type") == "Password") { <div class="form-group has-feedback @required"> <label for="@field.GetValue("Field.SystemName")" id="@field.GetValue("Field.SystemName")label" class="col-form-label control-label">@Translate(@field.GetString("Field.Name"))</label> @if (!string.IsNullOrEmpty(Convert.ToString(@field.GetValue("Field.Description")))) {<div id="@field.GetValue("Field.SystemName")Desc">@field.GetValue("Field.Description")</div>} <input type="@field.GetValue("Field.Type")" class="form-control" name="@field.GetString("Field.SystemName")" id="@field.GetValue("Field.SystemName")" value="@field.GetString("Field.Value")" placeholder="@field.GetString("Field.Placeholder")" data-error="" aria-labelledby="@field.GetValue("Field.SystemName")label" aria-describedby="@field.GetValue("Field.SystemName")Desc" @required data-bv-notempty-message='Udfyld venligst feltet "@Translate(@field.GetString("Field.Name"))"' data-bv-trigger="blur keyup" /> </div> } /*---------- Telefon felt ----------*/ else if (field.GetString("Field.Type") == "Tel") { <div class="form-group has-feedback @required"> <label for="@field.GetValue("Field.SystemName")" id="@field.GetValue("Field.SystemName")label" class="col-form-label control-label">@Translate(@field.GetString("Field.Name"))</label> @if (!string.IsNullOrEmpty(Convert.ToString(@field.GetValue("Field.Description")))) {<div id="@field.GetValue("Field.SystemName")Desc">@field.GetValue("Field.Description")</div>} <input type="@field.GetValue("Field.Type")" class="form-control" name="@field.GetString("Field.SystemName")" id="@field.GetValue("Field.SystemName")" value="@field.GetString("Field.Value")" placeholder="@field.GetString("Field.Placeholder")" data-error="" aria-labelledby="@field.GetValue("Field.SystemName")label" aria-describedby="@field.GetValue("Field.SystemName")Desc" @required data-bv-phone="@isRequired" data-bv-phone-country="DK" data-bv-notempty-message='Udfyld venligst feltet "@Translate(@field.GetString("Field.Name"))"' data-bv-trigger="blur keyup" /> </div> } /*---------- Textinput ----------*/ else if (field.GetString("Field.Type") == "TextInput") { <div class="form-group has-feedback @required"> <label for="@field.GetValue("Field.SystemName")" id="@field.GetValue("Field.SystemName")label" class="col-form-label control-label">@Translate(@field.GetString("Field.Name"))</label> @if (!string.IsNullOrEmpty(Convert.ToString(@field.GetValue("Field.Description")))) {<div id="@field.GetValue("Field.SystemName")Desc">@field.GetValue("Field.Description")</div>} <input type="@field.GetValue("Field.Type")" class="form-control" name="@field.GetString("Field.SystemName")" id="@field.GetValue("Field.SystemName")" value="@field.GetString("Field.Value")" placeholder="@field.GetString("Field.Placeholder")" data-error="" aria-labelledby="@field.GetValue("Field.SystemName")label" aria-describedby="@field.GetValue("Field.SystemName")Desc" @required data-bv-notempty-message='Udfyld venligst feltet "@Translate(@field.GetString("Field.Name"))"' data-bv-trigger="blur keyup" /> </div> } /*---------- Text ----------*/ else if (field.GetString("Field.Type") == "Text") { <div class="form-group has-feedback"> <div id="@field.GetValue("Field.SystemName")Desc">@field.GetValue("Field.Control")</div> </div> } /*---------- statisk billed felt ----------*/ else if (field.GetString("Field.Type") == "Image") { <div class="form-group @required"> <label for="@field.GetValue("Field.SystemName")" class="control-label">@field.GetValue("Field.Name")</label> @field.GetString("Field.Control").Replace(" id", " alt=\"\" id") <div>@field.GetString("Field.Description")</div> </div> } /*---------- Skjult felt ----------*/ else if (field.GetString("Field.Type") == "Hidden") { <div class="form-group has-feedback"> @if(FormName == "wcagfeedback"){ <input type="hidden" value="@RefUrl" id="skjult" name="skjult"> }else{ @field.GetString("Field.Control").Replace(" id", " value=\"\" id") } </div> } /*---------- default felt ----------*/ else if (field.GetString("Field.Type") != "Reset" && field.GetString("Field.Type") != "Submit") { <div class="form-group has-feedback @required"> <label for="@field.GetValue("Field.SystemName")" id="@field.GetValue("Field.SystemName")label" class="col-form-label control-label">@Translate(@field.GetString("Field.Name"))</label> @if (!string.IsNullOrEmpty(Convert.ToString(@field.GetValue("Field.Description")))) { ariaDescribedby = "aria-describedby='" + @field.GetValue("Field.SystemName") + "Desc'"; <div id="@field.GetValue("Field.SystemName")Desc">@field.GetValue("Field.Description")</div> } <input type="@field.GetValue("Field.Type")" class="form-control" name="@field.GetString("Field.SystemName")" id="@field.GetValue("Field.SystemName")" value="@field.GetString("Field.Value")" placeholder="@field.GetString("Field.Placeholder")" data-error="" aria-labelledby="@field.GetValue("Field.SystemName")label" @ariaDescribedby @required data-bv-notempty-message='Udfyld venligst feltet "@Translate(@field.GetString("Field.Name"))"' data-bv-trigger="blur keyup" /> </div> } } <!-- Show the messages in #errors --> <div class="form-group hide" id="errordiv" role="alert" aria-atomic="true"> <p><strong>Der er følgende fejl i formularen:</strong></p> <div class="col-sm-12"> <ul id="errors"></ul> </div> </div> @foreach (LoopItem field in GetLoop("Fields")) { string required = field.GetBoolean("Field.Required") ? "required" : ""; string ariareq = field.GetBoolean("Field.Required") ? "true" : "false"; string isRequired = field.GetBoolean("Field.Required") ? "true" : "false"; /*---------- Reset/annuller knap ----------*/ if (field.GetString("Field.Type") == "Reset") { <div class="form-group @required"> @field.GetString("Field.Control").Replace(" id", " class=\"btn btn-danger col-xs-4 col-sm-3 pull-right \" id") </div> } /*---------- Send/submit knap ----------*/ else if (field.GetString("Field.Type") == "Submit") { <div class="form-group @required"> @field.GetString("Field.Control").Replace(" id", " class=\"btn btn-primary col-xs-5 col-sm-3 pull-left \" id") </div> } } @GetValue("Form.FormEnd") <p> </p>