razor

Populating HTML5 Datepicker With Data Passed From A Model

北慕城南 提交于 2019-12-25 01:28:53
问题 I'm working on making a basic scheduling application for a project. We've implemented a simple DateTime picker to ease the process of selecting a start and end time/date for our events. The source code for this is: <input type="datetime-local" name="starttime" id="field1" /> The ending time calendar is the same barring the name. This works perfectly fine for taking in dates and time for events and we're quite happy with it. The issue is that when going to edit an entry the calendar does not

@Html.Label won't allow string concatenation

回眸只為那壹抹淺笑 提交于 2019-12-25 01:24:57
问题 I'm building dynamic forms based on a partial view. My view inherits a model with a single property: CatalogName { get; set; } . I have tried this: @Html.Label(Model.CatalogName + "-ProductNumber", "Product Number") @Html.TextBox(Model.CatalogName + "-ProductNumber") The HTML renders like this though: <label for>Product Number</label> <input name="CatatalogName-ProductNumber" type="text" /> If I write my code like this: @Html.Label("ProductNumber-" + Model.CatalogName", "Product Number") It

MVC Razor Html.Partial sub model

梦想的初衷 提交于 2019-12-25 01:22:49
问题 I have a problem concerning Partial views in MVC Razor. Any help is highly appreciated, it's most likely something I've missed, but I could find nothing while searching that had the same problem replicated. So I'm binding my view to a view model. public class Person { public string Name { get; set; } public virtual ContactInformation ContactInformation { get; set; } } And then I have a view with a partial to render the contact information model. <div> @Model.Name </div> <div> @Html.Partial("

Is there a way to bind a complex object to radiobutton

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-25 01:21:31
问题 I have a list of radiobuttons that I am generating from my model like this: @foreach (var offer in Model.AvailableOffers) { <div> @Html.RadioButtonFor(m => m.selectedAvailableOffer, offer) @Html.Label(offer.begin_date.Month + "/" + offer.begin_date.Day + " - " + offer.end_date.Month + "/" + offer.end_date.Day + ", " + offer.offer_name) </div> } Model includes these: public List<AvailableOffer> AvailableOffers { get; set; } public AvailableOffer selectedAvailableOffer { get; set; } See how I

DropDownListFor() bindling value AND text to viewmodel

天大地大妈咪最大 提交于 2019-12-25 01:14:45
问题 I have a form on a View with a dropdown list, implemented with DropDownListFor(). This View is strongly typed to a ViewModel, which has a SelectList property to hold the options of the dropdown, and then another property to hold the selected value of the dropdown. This is working fine, but what I'd like to do is, hold both the selected value AND selected text of the dropdown in my second property. The reason I want to do this is so that as the form selfposts, I have both the text and value of

How to control both the width and decimal places for a text box?

我们两清 提交于 2019-12-25 01:00:21
问题 MVC RAZOR VIEW Html.EditorFors decimal places can be controlled with Dataannotations but there is no easy (if any) way to control the width (they don't take htmlAttributes and setting a css class with a width has no effect). Html.TextBoxFors allow easy control of the width with htmlAttributes but there is no easy (if any) way to control the decimal places. How do you get an edit text box that you can control both the width and the decimal places? 回答1: and setting a css class with a width has

Pass model Id to partialView in order to edit

若如初见. 提交于 2019-12-25 00:08:58
问题 I have a list of Photography objects that I pass into a view:- Public class Photography { public Photography() { Name = ""; Description = ""; Category = ""; ImgUrl = ""; IsAccordion = false; } public string Name { get; set; } public string Description { get; set; } public string Category { get; set; } public string ImgUrl { get; set; } public bool IsAccordion { get; set; } } In my view I loop through the list like this: @foreach (var item in Model.Photographys) { <li class="span3" style="text

Executing an action on a controller in another area in .net

旧巷老猫 提交于 2019-12-24 20:39:51
问题 So I need to call an action on another controller in another area in .net Reason being I have some conditional logic to determine whether or not to display something and that is common to my website and mobile version. So in my mobile site(in a separate area called mobile) I would like to be able to do something like @Html.Action("GetVideoHtml","Service",null) Where Service is a controller in my default area and GetVideoHtml is the action, however again, I am in the mobile area. I could copy

OpenID in MVC3 (with Razor code)

血红的双手。 提交于 2019-12-24 19:15:17
问题 I use MVC3 with Razor code. I'm trying to use OpenID login for my application. Can anybody share the API code similar to that which Stack Overflow uses at homepage? 回答1: Here you have a full tutorial: http://weblogs.asp.net/haithamkhedre/archive/2011/03/13/openid-authentication-with-asp-net-mvc3-dotnetopenauth-and-openid-selector.aspx 来源: https://stackoverflow.com/questions/16693971/openid-in-mvc3-with-razor-code

How to display html elements beside each other

孤街醉人 提交于 2019-12-24 19:09:03
问题 I have the following code inside my asp.net MVC Razor view: <p> @using (Html.BeginForm()) { @Html.ValidationSummary(true) @Html.HiddenFor(model => model.GroupID) @Html.Partial("_CreateOrEdit", Model) <input type="submit" value="Save" class="btn btn-primary"/> } @using (Html.BeginForm("Index", "SecurityGroup", FormMethod.Get)) { <input type='submit' value='Cancel' class='btn' /> } </p> How I can force the two <input /> elements to be displayed beside each other, instead of being under each