I have many problem in asp.net because i am new with that . so i searched but i did not find my answer.
First of all my view engine is aspx is not razor and it is my mostly problem .
this is View
<%= Html.HiddenFor(model => model.SharingPremiumHistoryID) %>
<%= Html.HiddenFor(model => model.ItemId) %>
<div class="group">
<span> ارسال به </span>
<%= Html.DropDownListFor(model => model.SharingTargetType, Model.SharingTypes) %>
</div>
</hgroup>
<div class="newseditor">
<div class="input-form">
<%= Html.LabelFor(model => model.SharingTitle, "عنوان خبر") %>
<%= Html.TextBoxFor(model => model.SharingTitle) %>
</div>
<div class="input-form">
<%= Html.LabelFor(model => model.Content, "متن خبر") %>
<%= Html.TextAreaFor(model => model.Content) %>
</div>
<div><input id="fileUpload" type="file" />
</div>
<button name="post" type="submit" >ارسال خبر</button>
as you so i have some item that fill the model .
now my question is how i pass this view to controller(with out Ajax) with submit button .
and this is controller
public virtual ActionResult Add()
{
var model = new ResturantSharingViewModel();
model.SharingTargetType = getSharingTargetTypesSelectListItems();
return PartialView(model);
}
You need to use a Html.BeginForm
and add HttpPost
to the controller action.
Have this code in your view:
<% using(Html.BeginForm("HandleForm", "Home")) %>
<% { %>
// your code for your page goes here
<input type="submit" value="Submit" />
<% } %>
Then have code like this in your controller:
public ActionResult HandleForm()
{
// do controller logic here
return View("FormResults");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With