TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Lionel Slade
NA
2
434
Read values from Labels
Dec 2 2016 5:16 AM
How do I get the values in my controller from the labels?
MVC Page
@using (Html.BeginForm("EditSubscriptionCurrent", "Subscriptions", FormMethod.Post))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<td class="editor-field">
Subsciption Package Sent: <input id="cbSubPackSent" name="cbSubPackSent" type="checkbox" value="checked" />
</td>
<td class="editor-field">
Subsciption Package Sent By: <label id="UserNameUN" name="UserNameUN">@ViewBag.UserName</label>
</td>
<td class="editor-field">
Subsciption Package Sent Date: <label id="DateTimeDT" name="DateTimeDT">@ViewBag.DateTime</label>
</td>
<td>
<input type="submit" value="Save" />
</td>
}
Controller
string searchString = Request.Form["SearchString"];
//var subscriptions = subscriptionsAll.Where()
int count;
IQueryable subscriptions = FilterSubscriptions2(subscriptionsAll, _subscriptionPackSerach, currentFilter, out count);
foreach (SUBSCRIPTION subscription in subscriptions)
{
//update subPackStatus
var r = (Request.Form["cbSubPackSent"] == "checked") ? true : false;
bool checkedStatus = Convert.ToBoolean(r);
subscription.SubPackSent = checkedStatus;
var
userName
= Request.Form["UserNameUN"];
var UN = ViewBag.UserName;
subscription.SubPackSentBy = userName;
var dt2 = ViewBag.DateTime;
DateTime
dt
= Convert.ToDateTime(Request.Form["DateTimeDT"]);
subscription.SubPackSentDate = dt;
ctx.Entry(subscription).State = EntityState.Modified;
}
//MvcApplication._subscriptionsPackUpdate = subscriptionsPackUpdate;
ctx.SaveChanges();
UserName & dt return null. r returns a value
Reply
Answers (
2
)
Watermark on dropdownlist
i need to display Jquery fancy box