Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading multiple viewcomponents in an ASP.net core 2.2 cshtml

I'm new to Asp.Net core but i have worked with Asp.net MVC 5.I have a problem with loading multiple view components inside a view.(using Asp.net core 2.2) I have page which loads a viewcomponent inside it. This is my page:

    <div id="frmSoftPhone_pageUniqueId">
            <div id="sipClient" class="custom-tab">
                <ul>       

                     <li class="active"
                            data-init="init"
                            data-parentObj="cc.pageDesktop"><i class="icon-desktop"></i></li>
                </ul>
               <div id="desktop-container" class="active" style="height: 650px">
                        @await  Component.InvokeAsync("TestViewComponent")
                    </div>
            </div>
        </div>

And then inside my 'TestViewComponent' i am loading a few viewcomponents too. my TestViewComponent is this

    @{
        Layout = null;
    }

    <div class="container">
        <div class="container-item">
            <div class="custom-tab">
                <ul>
                    <li class="active session-content-li"><i class="fa fa-file-text"></i></li>
                    <li><i class="fa fa-users"></i></li>
                    <li style="position: relative">
                        <span id="v-call-count" style="display: none">0</span><span class="icon-queue"></span>
                    </li>
                    <li style="position: relative">
                        <span id="p-call-count" style="display: none">0</span><span class="icon-p-queue"></span>
                    </li>
                </ul>
                <div class="active session-content">
                    @await Component.InvokeAsync("GroupEmail", new GroupEmailModel())
                    @await Component.InvokeAsync("CallHistory")
                    @await Component.InvokeAsync("SmsContainer")
                </div>
                <div>
                    <div class="tabcontent">
                        @await Component.InvokeAsync("OnlineAgentstatus")
                    </div>
                </div>
                <div>
                    <div class="tabcontent">
                        @await Component.InvokeAsync("VCallsContainer")
                    </div>
                </div>
                <div>
                    <div class="tabcontent">
                        @await Component.InvokeAsync("PCallsContainer")
                    </div>
                </div>

            </div>
        </div>
    </div>

None of my viewcomponents have 'async' code.By debugging I see that all my viewcomponents are loading by trace but finally when everything finishes there is just first component 'GroupEmail'.Also when changing the loading order of the viewcomponents, again just first one or sometimes 2 of them is loaded inside the HTML.Also I tried using Html.PartialAsync and Html.Partial too.but the same result happened. I'm getting stuck on this problem for 2 days.Any help i'll appreciate.

Thanks

like image 482
Joshua Austin Avatar asked Aug 11 '26 08:08

Joshua Austin


1 Answers

Finally found,

There was a mistake on kendo model wrong binding in a column.So just corrected it and all the viewcomponents are working correctly now.

like image 198
Joshua Austin Avatar answered Aug 14 '26 12:08

Joshua Austin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!