Telerik Forums
UI for ASP.NET MVC Forum
1 answer
97 views

Hi,

 

I have a kendo grid, user wants to enter html data in one of the column.

user clicks edit button on the grid row then an edit form opens as popup. This edit form is a model.cshtml with all the fields of the model on it. This edit cshtml does not have any button on it. "Update" button is created on fly.

User enters html data (tags etc) and clicks Update button then it return 401 error. Which I think is because its taking the tags as an injection attack. If user enters normal text then it works fine.

what can do to make the edit form allow submit html tags data? can you please help me?

 

Thanks

CNS

Anton Mironov
Telerik team
 answered on 12 Jul 2023
0 answers
82 views

Hello,

My web application has a grid and in each line there is an edit button that opens a popup with a registration form as shown in the image.

1. I would like to configure the prev and next buttons to cycle through the database records

I saw an example exactly how I wanted it to be but I couldn't implement it

https://dojo.telerik.com/EBepu

Grid:

@(Html.Kendo().Grid<SgmWebEsocial.Models.FuncionarioViewModel>()
            .Name("Funcionarios")
            .Columns(columns =>
            {
                columns.Bound(p => p.PessoaFisica_FotoPessoa)..Width(70).Filterable(false).Sortable(false);
                columns.Bound(p => p.Pessoa_Nome).Width(200).Title("Nome");
                columns.Bound(p => p.MatriculaFuncionario).Width(80).Title("Matrícula");
                columns.ForeignKey(c => c.IdNivelCargo, (System.Collections.IEnumerable)ViewData["nomeCargo"], "IdNivelCargo", "NomeCargo").Title("Cargo").Width(120);
                columns.ForeignKey(c => c.TipoSituacaoFuncionario, (System.Collections.IEnumerable)ViewData["tipoSituacaoFuncionario"], "IdTipoSituacaoFuncionario", "NomeTipoSituacaoFuncionario").Title("Situação").Width(90);
                columns.ForeignKey(p => p.IndicativoTipoEnvioEsocial, (System.Collections.IEnumerable)ViewData["envioEsocial"], "IdTipoEnvioEsocial", "NomeTipoEnvioEsocial").Title("Esocial").Width(80);
                columns.Command(command => { command.Edit(); command.Destroy(); }).Width(150);
                columns.Bound(p => p.IdFuncionario).Title("Ação").ClientTemplate("<a onclick=\"showProgress()\" href='" + @Url.Action("ExportEsocial", "Funcionario", new { idFuncionario = "#=IdFuncionario#" }) + "' class='k-button'>&nbspEnviar eSocial</a>").Width(70);
            })
                //.Events(e => e.Edit("onEdit"))
                .ToolBar(toolbar => toolbar.Create())
                .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("CadFuncionario").Window(w => w.Title("Cadastro de Funcionários").Width(1100)))
                .Pageable()
                .Sortable()
                .Filterable()
                .Scrollable(scr => scr.Height(450))
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .PageSize(6)
                    .Events(events => events.Error("error_handler"))
                    .Model(model =>
                    {
                        model.Id(p => p.IdFuncionario);
                    })
                    .Create(update => update.Action("AdicionaFuncionario", "Funcionario").Data("sendAntiForgery"))
                    .Read(read => read.Action("ListaFuncionario", "Funcionario"))
                    .Update(update => update.Action("EditaFuncionario", "Funcionario").Data("sendAntiForgery"))
                    .Destroy(update => update.Action("RemoveFuncionario", "Funcionario").Data("sendAntiForgery"))
                            .Sort(sort =>
                            {
                                sort.Add(p => p.Pessoa_Nome);
                            })
                )

            )

Controller:

//Fill in the form [KendoGrid] public virtual JsonResult ListaFuncionario([DataSourceRequest] DataSourceRequest request) { var context = new DbSgmContext();

            var pessoaFisica =
context.PessoasFisicas;

var result = funcionario.ToDataSourceResult(request, u => new FuncionarioViewModel { //Data Table Pessoa Pessoa_Nome = u.Pessoa.Nome, Pessoa_DDD = u.Pessoa.DDD_Telefone, Pessoa_DDD_Celular = u.Pessoa.DDD_Celular, Pessoa_Celular = u.Pessoa.Celular, Pessoa_Telefone = u.Pessoa.Telefone, Pessoa_Email = u.Pessoa.Email, Endereco_Numero = u.Pessoa.NumeroEndereco, Endereco_Complemento = u.Pessoa.Complemento,

  //Data Table PessoaFisica
                PessoaFisica_FotoPessoa = pessoaFisica.Single(pf => pf.IdPessoa == u.IdPessoa).FotoPessoa,
                PessoaFisica_CPF = pessoaFisica.Single(pf => pf.IdPessoa == u.IdPessoa).CPF,
                PessoaFisica_DataNascimento = pessoaFisica.Single(pf => pf.IdPessoa == u.IdPessoa).DataNascimento,
                PessoaFisica_NomeSocial = pessoaFisica.Single(pf => pf.IdPessoa == u.IdPessoa).NomeSocial,
                PessoaFisica_TipoSexo = pessoaFisica.Single(pf => pf.IdPessoa == u.IdPessoa).TipoSexo,
                PessoaFisica_NomePai = pessoaFisica.Single(pf => pf.IdPessoa == u.IdPessoa).NomePai,
                PessoaFisica_NomeMae = pessoaFisica.Single(pf => pf.IdPessoa == u.IdPessoa).NomeMae,
                PessoaFisica_EstadoCivil = pessoaFisica.Single(pf => pf.IdPessoa == u.IdPessoa).IdTipoEstadoCivil,
                PessoaFisica_RacaCor = pessoaFisica.Single(pf => pf.IdPessoa == u.IdPessoa).IdTipoRacaCor, }); returnthis.Json(result); }

Rafael
Top achievements
Rank 1
 asked on 02 Jul 2022
Narrow your results
Selected tags
Tags
+? more
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?