Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9231551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:05:53+00:00 2026-06-18T06:05:53+00:00

I have a partial View, which I am trying to load twice onto a

  • 0

I have a partial View, which I am trying to load twice onto a cshtml file.

Now inside my partial View I have a javascript function as well. At this point, when I load my
cshtml onto the page, I will have two Javascript functions with same name.

I want to avoid this kind of scenario and name the Javascript function uniquely depending upon the Model which I am binding the Partial View to.

Please Not I could achieve the uniqueness for each control inside my partial by associating it with a parameter like “@Model.Id”. But I am unable to apply the same kind of thing for uniqueness of Javascript function.

I am sorry for my Bad English. Kindly let me know if you need additional details.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:05:54+00:00Added an answer on June 18, 2026 at 6:05 am

    In order to achieve scenario like that you can use data-attribute.

    For example we have identical html code surrounded by a div, those div’s had different id.

    Each div will have a data-attribute and with jquery you can catch an event (Like Click)

    Now Code Example

    HTML

    <div id="id1" data-attribute="doSomething">Element</div>
    <div id="id2" data-attribute="doSomething">Element</div>
    

    In your case those div represent the results coming from the partial view
    also you can change the value store in the id attribute to come from your model something like id="id@{Model.Id}"

    JQuery

    $("div[data-attribute=doSomething]").click(function() {
        alert("Clicked element: " + $(this).prop("id")); 
    });
    

    Fiddel Example

    I am using attribute selector of Jquery to achieve it

    Note That you can achieve it also by defining a class attribute.
    But I think you should use this when you actually need a class otherwise use custom attribute like data-value="something"

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a partial view which contain JavaScript and Ajax, but does not run
I have a partial view in which I am trying to get the values
I have a partial view which is displayed on the top right of every
I have a view Details which consists of a partial view _Tabs and a
Hi guys i have controller which returns a partial view, the controller is called
I have a partial view that is shared between two controllers and I'm trying
I am trying to create simple CRUD application. I have a partial view that
I am teaching myself asp .net mvc3. I have a partial view which uses
I have a view that has some jQuery to load a partial view (via
I have a view and a loop within which a partial view is rendered.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.