setting html link href attribute with jquery or javascript in mvc razor page

Hi experts,

I have a mvc 5 application using C#, Razor, jquery.

This is a followup to this ticket:¬ificationFollowed=208651180#a42592893

in my view on my table my link is set like this it works fine:

<a id="ReportLink" target="_blank" href="">@Html.DisplayFor(modelItem => item.EmployeeID)</a>

Because on click i want user to got to

<a id="ReportLink" target="_blank" href="">@Html.DisplayFor(modelItem => item.EmployeeID)</a>

Is there a way to set the href attribute to

Having a Javascript variable called firstpartofhref = "" and then set it in the href before the @razor tag something like this?

 href=" firstpartofhref + @item.EmployeeID"

can i just store this razor tag @item.EmployeeID in a javascript variable called secondpartofhref also?

and then set the href attribute something like this?

 href=" firstpartofhref + secondpartofhref"
Who is Participating?
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.

The Razor engine does not parse Javascript files, only Razor views. You can setting the variables inside your Razor view.
For example,
  var YourVariable= '@item.EmployeeID';
// create link
var a = document.createElement('a');
var linkText = document.createTextNode("my title text");
a.title = "my title text";
a.href = "" + YourVariable;

Open in new window

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
There is no activity from author.
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

From novice to tech pro — start learning today.