如何设置自定义属性而不在浏览器上显示它?

时间:2019-05-13 12:31:17

标签: razor

我在cshtml视图上创建了一个int类型的属性以用作计数器,当我在其上设置一个值时,它就会在我的Web窗体上显示。我该如何预防?

  

Blockquote代码   PROBLEM

int countResposta = 0;

@foreach(questionarioDTO.Questoes.OrderBy(s => Guid.NewGuid())。ToList()中的var questao) {                                                                                                                                                                                                                                                                                                                                                                                                                                                                               @count)@ questao.Descricao

@ *当我在此处设置值时,它将在浏览器上显示蜜蜂* @ @(countResposta = 0)

@foreach(questao.Respostas.OrderBy(s => Guid.NewGuid())。ToList()中的var resposta                                                             {                                                                  @(alfa [countResposta])。 @ Html.RadioButton(questao.IdQuestao.ToString(),resposta.IdResposta.ToString(),新的{@id = resposta.IdResposta.ToString()}) @ resposta.Descricao                                                                 countResposta ++;                                                             }                                                                                                                                                                               @ style =“位置:固定;底部:0像素;右侧:310像素;边框:无”> @                                                                                                                              @if(计数> 1)                                                                 {                                                                     前部                                                                 }

                                                            @if (MaxRegistros > count)
                                                            {
                                                                <a href="#etapa@(count + 1)" id="linkEtapa@(count + 1)" onclick="$(document).scrollTop(0);" aria-controls="etapa@(count + 1)" role="tab" data-toggle="tab" class="btn btn-success ripple"><span class="ink animate" style="height: 134px; width: 134px; top: -45px; left: 31.5781px;"></span><i class="fa fa-chevron-right fa-fw"></i>Próxima</a>
                                                            }
                                                            else
                                                            {
                                                                <a id="aSalvar" class="btn btn-primary btn-success-geg" onclick="javascript: SalvarForm();"><span class="glyphicon glyphicon-floppy-disk"></span>&nbsp;<strong>Finalizar</strong></a>
                                                            }

                                                            @*<a id="aSalvar" class="btn btn-primary btn-success-geg" onclick="javascript: SalvarForm('@ViewBag.CodigoEmpregadoPesquisa');"><span class="glyphicon glyphicon-floppy-disk"></span>&nbsp;<strong>Finalizar</strong></a>*@
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    count++;
                }
  

结果resultado

1 个答案:

答案 0 :(得分:0)

需要使用以下命令: @ {countResposta = 0; } @ *需要在{,} * @

之前和之后设置空格

而不是:

@(countResposta = 0)