Bundle javascript in partial view to use as widget

Hi All,

I would like to create a small widget where it contains a search box a submit button and 3 labels and 3 texboxes for displaying employee name , email, phone number. So whenever employee id is entered and upon clicking submit button I would like to make an ajax call to my controller and get the details and fill the partial view. I do not want the ajax call in main view because that will not enable me to use it in other views.

How do I achieve this? Thanks for your time.
JyozealAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
I am not sure what you are looking for, but you should be able to add the script reference in the parent view, and call the function in the partial view.
JyozealAuthor Commented:
Thanks for your comment. In that case I will not be able to use it as unit. My intention is to use it in various views of my project by just inserting this partial view along the with script. I do not want each view to duplicate the code to load employee details in partial view.
Bob LearnedCommented:
I don't believe that you can add a script reference to a partial view, but there might be some other approaches that I don't know about yet.

Take a look here:

Managing Scripts for Razor Partial Views and Templates in ASP.NET MVC
http://forloop.co.uk/blog/managing-scripts-for-razor-partial-views-and-templates-in-asp.net-mvc#sthash.koeye0dE.dpbs
Jitendra PatilSr.Software EngineerCommented:
I am not an expert with MVC but i think you can get a good reference on the below links
Adding to script bundle from partial view in .NET MVC 5
Adding to script bundle from partial view in .NET MVC 5
hope this helps.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.