We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Partial view with EJ2 controls do not work if added more than once on the page

Hi,

I have a file uploader inside a partial view. If I add more than one partial view on a razor page, only the uploader in the 1st partial view renders, the rest don't. How can I get multiple partial view instances to correctly render ejs controls.

Full Project is attached

Thanks

Avinash Tauro


Attachment: WebApplicationEj2Partial_b211c8fe.zip


3 Replies

UD UdhayaKumar Duraisamy Syncfusion Team March 23, 2023 01:19 PM UTC



AV Avinash March 23, 2023 07:20 PM UTC

Hi,


You have shared a the introductory explanation of how to use partial views. I know how to use partial views and my problem is specifically when using a partial view twice on the page.


The example in your link uses the partial view only once . When I change the code in your example to display partial view twice, I see the exact same error.


Also I am using Razor Pages while both these examples are for MVC. 

Additionally in Razor Pages you can simply use <partial name="partialViewName" /> rather than javascript as in your example.


Anyway my problem irrespective of whether its MVC or Razor pages, is only when I use the partial view twice in my Razor Page.


Thanks

Avinash Tauro



PK Priyanka Karthikeyan Syncfusion Team March 24, 2023 03:04 PM UTC

Hi Avinash,


To resolve this issue, you can try using unique IDs for each file uploader instance inside the partial views. By default, the IDs of the ejs controls generated in partial views will be the same across all instances, which can cause conflicts and issues with rendering.

For example, you can use the following code to generate a unique ID for each file uploader:

@{

    string uploaderId = "uploader_" + DateTime.Now.Ticks.ToString();

}

<div class="rounded bg-light pt-3 pb-3">

    <div>

        <ejs-uploader id="@uploaderId"></ejs-uploader>

    </div>

    <div>

        <label for="txtSomeThing">Enter something here: </label>

        <input type="text" id="txtSomeThing" />

    </div>

</div>


Regards,

Priyanka K


Attachment: ModifiedSample_d4caeb31.zip


Loader.
Up arrow icon