Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
actually what i want to do is?
i want to show the if (model.IsItem==true)
i want to show certain div as it is item in edit view
and if false then i want to hide this
how can i do that ?
plz help !!
controller :
C#
public ActionResult Edit(int id )
 {
 var ParamToEdit = (from pd in _db.Dog join p in _db.animal on pd.dogid equals p.animalid
                    where pd.dogid == id
                    select new ArticleRepository { dog = pd, animal = p }).First();  
                     ViewBag.DTypes = (dat.GetStateName());
                     ViewBag.dp = (dat.GetTrueFalse()); 
                  return View(ParamToEdit);
            }

view--
HTML
@model MvcDemo.Models.ObjectManager.ArticleRepository
 
@{
      ViewBag.Title = "Edit";
}
   @using (Html.BeginForm())
         {
            @Html.ValidationSummary(true)  
            <ul><h2>Parameter</h2></ul>
            <div class="editor-label">
                  @Html.LabelFor(model => model.cat.catid)
            </div>
            <div class="editor-field">        
                  @Html.DisplayFor(model => model.cat.catid)
                  @Html.ValidationMessageFor(model => model.cat.catid)
            </div>
 
            <div class="editor-label">
                  @Html.editorfor(model => model.dog.dogid)
            </div>
if(model.animal.animaltype==dog)
{
   <div>@html.editorfor(model=model.dog.dogname)</div>
}
else hide this;
Posted
Updated 8-Mar-12 21:53pm
v3
Comments
Aniket Yadav 9-Mar-12 3:33am    
Post your sample code...

1 solution

you can save the true/false in ViewData
ex:
C#
if (model.IsItem==true)
ViewData["IsItem"]="show"


In the document.ready check this data and apply a css class to div.
ex:
C#
if ('<% =ViewData["IsItem"] %>'=='show')
$('#divId').addclass('show');


and define the show css class,such as:
C#
 .show
{
display:block;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900