Send C#/razor to javascript function -


how can make work:

@foreach (var alert in model.alertsrelatedtobrand)  {      <li class="notifications-row">          <div class="notifications-icon notifications-icon-alert">&nbsp</div>          <div class="notifications-text"><a>@alert.title</a></div>          <a href="#" class="notifications-dismiss" onclick="onhidealertclick(@alert.id)">x</a> // here problem      </li> } 

i want send id of each alert function if item clicked.

your code appears correct use of @alert.id should output value existing onhidealertclick() function :

onclick="onhidealertclick(@alert.id)" 

it's worth noting if id property integer, may want try wrapping parameter within single quotes pass along string seen below :

onclick="onhidealertclick('@alert.id')" 

Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -