amir_arsalan_k2
دوشنبه 05 خرداد 1393, 14:10 عصر
من چند تا فرم مختلف دارم که تو هر کدوم از آنها اطلاعات مختلف وجود داره و میخوام با انتخاب گروه های مختلف فرم مخصوص خودش به نمایش در بیاد
مثلا وقتی گروه ماشین انتخاب میشه فیلد های مخصوص ثبت ماشین و وقتی موبایل انتخاب میشه فیلد های مخصوص خودش ....
اینم کدها ی صفحه html
@{
ViewBag.Title = "Newads";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>اضافه کردن آگهی جدید</h2>
@using (Ajax.BeginForm("Newads", "Home", new AjaxOptions { HttpMethod = "Post" }, new { @id = "Form1" }))
{
<div>
<div>
<div></div>
</div>
<div></div>
<div></div>
<div>
@Html.DropDownList("Category", new SelectList(ViewBag.CatList, "ID", "name"), "گروه خود را انتخاب کنید", new { @class = "form_input", Style = "width:50%" })
</div>
<div class="clear"></div>
</div>
}
<div class="clear"></div><div class="clear"></div><div class="clear"></div>
@{<hr />}
@using (Ajax.BeginForm("Newads", "Home", new AjaxOptions { HttpMethod = "Post" }, new { @id = "Form2" }))
{
<div>
@Html.Label("تست")
@Html.TextBox("name", null, new { @class = "form_input" })
</div>
<div class="clear"></div>
<div>
@Html.Label("تست")
@Html.TextBox("name", null, new { @class = "form_input" })
</div>
<div class="clear"></div>
<div>
@Html.Label("تست")
@Html.TextBox("name", null, new { @class = "form_input" })
</div>
<div class="clear"></div>
<div>
@Html.Label("تست")
@Html.TextBox("name", null, new { @class = "form_input" })
</div>
}
<div class="clear"></div>
@using (Ajax.BeginForm("Newads", "Home", new AjaxOptions { HttpMethod = "Post" }, new { @id = "Form3"}))
{
<div>
@Html.Label("فرم ماشین")
@Html.TextBox("name", null, new { @class = "form_input" })
</div>
<div class="clear"></div>
<div>
@Html.Label("فرم ماشین")
@Html.TextBox("name", null, new { @class = "form_input" })
</div>
<div class="clear"></div>
<div>
@Html.Label("فرم ماشین")
@Html.TextBox("name", null, new { @class = "form_input" })
</div>
<div class="clear"></div>
<div>
@Html.Label("فرم ماشین")
@Html.TextBox("name", null, new { @class = "form_input" })
</div>
}
اینم کد سمت Control
public ActionResult Newads()
{
ViewBag.CatList = catlist.Select();
ViewBag.Ostanlist = ostanlist.Select();
return View();
}
اما چطور ID در موقع select فیلد Dropdown بگیرم و فرم مخصوص مشون بدم ؟
کسی هست کمکم کنه ؟
مثلا وقتی گروه ماشین انتخاب میشه فیلد های مخصوص ثبت ماشین و وقتی موبایل انتخاب میشه فیلد های مخصوص خودش ....
اینم کدها ی صفحه html
@{
ViewBag.Title = "Newads";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>اضافه کردن آگهی جدید</h2>
@using (Ajax.BeginForm("Newads", "Home", new AjaxOptions { HttpMethod = "Post" }, new { @id = "Form1" }))
{
<div>
<div>
<div></div>
</div>
<div></div>
<div></div>
<div>
@Html.DropDownList("Category", new SelectList(ViewBag.CatList, "ID", "name"), "گروه خود را انتخاب کنید", new { @class = "form_input", Style = "width:50%" })
</div>
<div class="clear"></div>
</div>
}
<div class="clear"></div><div class="clear"></div><div class="clear"></div>
@{<hr />}
@using (Ajax.BeginForm("Newads", "Home", new AjaxOptions { HttpMethod = "Post" }, new { @id = "Form2" }))
{
<div>
@Html.Label("تست")
@Html.TextBox("name", null, new { @class = "form_input" })
</div>
<div class="clear"></div>
<div>
@Html.Label("تست")
@Html.TextBox("name", null, new { @class = "form_input" })
</div>
<div class="clear"></div>
<div>
@Html.Label("تست")
@Html.TextBox("name", null, new { @class = "form_input" })
</div>
<div class="clear"></div>
<div>
@Html.Label("تست")
@Html.TextBox("name", null, new { @class = "form_input" })
</div>
}
<div class="clear"></div>
@using (Ajax.BeginForm("Newads", "Home", new AjaxOptions { HttpMethod = "Post" }, new { @id = "Form3"}))
{
<div>
@Html.Label("فرم ماشین")
@Html.TextBox("name", null, new { @class = "form_input" })
</div>
<div class="clear"></div>
<div>
@Html.Label("فرم ماشین")
@Html.TextBox("name", null, new { @class = "form_input" })
</div>
<div class="clear"></div>
<div>
@Html.Label("فرم ماشین")
@Html.TextBox("name", null, new { @class = "form_input" })
</div>
<div class="clear"></div>
<div>
@Html.Label("فرم ماشین")
@Html.TextBox("name", null, new { @class = "form_input" })
</div>
}
اینم کد سمت Control
public ActionResult Newads()
{
ViewBag.CatList = catlist.Select();
ViewBag.Ostanlist = ostanlist.Select();
return View();
}
اما چطور ID در موقع select فیلد Dropdown بگیرم و فرم مخصوص مشون بدم ؟
کسی هست کمکم کنه ؟