Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Deepa 14 posts 71 karma points
    May 21, 2015 @ 14:17
    Deepa
    0

    PartialView Macro in content page

    I have to use a partial view macro inside a content page.The partial view shows data from database.Could please suggest me a solution for this requirement

  • Urvish 252 posts 776 karma points
    May 21, 2015 @ 14:20
    Urvish
    0

    Hi Deepa,

    You need to make that parial view under \Views\MacroPartials folder.

    Then you will we able to add that partial view in Macro.

    After that you can easily call macro inside template.

    Hope it will help.

    Regards,

    Urvish Mandaliya

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    May 21, 2015 @ 14:21
    Alex Skrypnyk
    0

    Hi Deepa,

    You can use Umbraco database context class, like here http://creativewebspecialist.co.uk/2013/07/16/umbraco-petapoco-to-store-blog-comments/

    var db = ApplicationContext.Current.DatabaseContext.Database;
    // Fetch a collection of contacts from the db.
    var listOfContacs = db.Fetch<Contact>(new Sql().Select("*").From("myContactsTable"));
    

    Thanks, Alex

  • Deepa 14 posts 71 karma points
    May 21, 2015 @ 14:22
    Deepa
    0

    I need to show datas from database in that partial view.

  • Urvish 252 posts 776 karma points
    May 21, 2015 @ 14:28
    Urvish
    0

    ok you can make DB call in partial view as Alex gave like below.

    @{
        var db = ApplicationContext.Current.DatabaseContext.Database;
        // Fetch a collection of contacts from the db.
        var listOfContacs = db.Fetch<Contact>(new Sql().Select("*").From("myContactsTable"));
    
        }
    

    Regards,

    Urvish Mandaliya

Please Sign in or register to post replies

Write your reply to:

Draft