0

hi friends help me to get out of this..

//controller
{
ViewData["idvalue"]="id"+1;
return View();
}
// Viewpage

<div id="?? "> id has to set as id1..

help me, how i can set div id as id1..?

thanks in advance.

regards,

tereško
  • 58,060
  • 25
  • 98
  • 150
Cooldharma06
  • 515
  • 1
  • 6
  • 24

2 Answers2

3

Use

//controller
{
  ViewData["idvalue"] ="id1";
  return View();
}
// Viewpage

<div id='@ViewData["idvalue"]'>

However, I would recommend to use ViewBag instead of ViewData

Satpal
  • 132,252
  • 13
  • 159
  • 168
1
{
ViewBag.idvalue ="id1";
return View();
}
// Viewpage

<div id='@ViewBag.idvalue'>

I recommend using ViewBag instead. It's just a nicer wrapper for ViewData

TGH
  • 38,769
  • 12
  • 102
  • 135