ASP.NET MVC and Angular Training in Mumbai :- @Razor and JavaScript

Again a big thanks to our students to make our MVC training in Mumbai Andheri successful. It was small batch of 4 people and this time we had some people travelling from Pune as well.

One of the interesting learning that happened in this MVC training was razor symbol and javascript clash.

We had a very simple javascript code which was running inside razor engine and we wanted to set a twitter id to the javascript variable. But because the twitter id had a “@” symbol razor was throwing exception.

1

In case you are thinking that with two “@@” it should work and then let me confirm it will not.We wanted to display in the javascript alert only one ‘@’ so this was not the solution for it.

2

This was solved by using “Html” helper. So from the server side we will tell HTML helper to parse the “@” and set send it as javascript code to the browser. This worked a like a charm. We understand its not a great solution but it solved our problem.

var twitter = @Html.Raw("'@shivkoirala'");
alert(twitter);

Thanks to our participants to attend this MVC training our next MVC training will start this coming Saturday and Sunday. Do not miss our 16 hours of action in our Mumbai Andheri training institute. For syllabus and venue you can see this link www.stepbystepschools.net/?page_id=315.

Comments

comments

This entry was posted in Angular Mumbai Training, Class Room Training, MVC and tagged , , . Bookmark the permalink.

4 Responses to ASP.NET MVC and Angular Training in Mumbai :- @Razor and JavaScript

  1. Vikramaditya Shinde says:

    Hi Sukesh ,

    Please let me know the training schedule in March 2016.Also need to know what will be cover in next sessions.
    Thanks.

    View Comment
  2. Rashmi says:

    Hi,

    I want to attend Mvc training.
    When you are conducting next session?
    I also want to know what topics you cover in 2 days?

    View Comment

Leave a Reply

Your email address will not be published.