Code: Detail

Especializações:Asp.net, Ajax, C#, Visual Basic.net, Wcf, XML FrameWork .net 1.1, 2.0 e 4.0, OO, Design Patterns Arquitetura SOA, DDD, MVP e MVVM Html, Css, JavaScript Sql Server 2000, 2005 e 2008 Oracle 8i e 9i Asp3, Visual Basic 6 e COM+

asp.net-core-2 - (Portuguese)

Criando e usando ViewComponents

Rotina que mostra como criar e exibir um viewcomponent em uma view no asp.net core 2.0

Last update: 21/01/2018
asp.net-core-2       
 
N/A
N/A
N/A
N/A
 

//No seu projeto web crie a pasta ViewComponents e Crie a classe FiltrarImoveis

using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace SeuProjetoWeb.ViewComponents
{
    public class FiltrarImoveis : ViewComponent
    {
        public FiltrarImoveis()
        {

        }

        public IViewComponentResult Invoke()
        {
            return View();
        }
    }
}



//Na pasta Views/Shared Crie a pasta Components e dentro da pasta Components a pasta FiltrarImoveis
//Em Views/Shared/Components/FiltrarImoveis crie a View Default.cshtml


@{
    Layout = null;
}


<br />
<br />
    View compontent Filtrar Imoveis
<br />
<br />


//Para poder exibir o seu viewcomponent por tagHalper, em _ViewImports.cshtml acrescente
@addTagHelper *, NomeProjetoWeb



//Para testar em Views/Home/Index.cshtml acrescente o codigo abaixo.


<br />
<br />
Teste inicio index
<br />
<br />
<vc:filtrar-imoveis></vc:filtrar-imoveis>
<br />
<br />
teste fim index
<br />
<form asp-controller="Home" asp-action="Index" method="post"></form>

Source:
 
Users who have marked this routine as a favorite
 
 
 
The site ti4fun is not responsible for the content on sites for which you have external links

Articles, routines, tips, forums, blogs or any other content posted on ti4fun site is not tested and not validated, so you should test and validate any information collected on the ti4fun site before applying it to final use environment, such as example, production. the TI4FUN site is not responsible for quality or for any damages, direct, indirect or consequential, from use of any content posted by the authors in the site.

All content published on the ti4fun site is the responsibility of the author and do not necessarily express the views of the site ti4fun and its employees.