razor

Using javascript variable in ASP.NET View with WebGrid Column

孤街醉人 提交于 2019-12-23 04:47:12
问题 I am trying to display a javascript variable in my WebGrid column. Use of javascript is must as I am finding the corresponding client side date-time. I created my webgrid in cshtml view head WebGrid grid = new WebGrid(Model,...) Then inside begin form I try populate it (with date manupulation) as follows:- grid.Table( tableStyle: "table table-bordered", columns: grid.Columns( grid.Column("FirstCol", "First Column"), grid.Column("SometTime", "Local Time", format: @<text> @{ var sDate="";

what decimal value got rounded in Razor view?

天涯浪子 提交于 2019-12-23 04:45:10
问题 My model contains a decimal column, I have checked inside Controller action it has decimal values like below: 0.69874 0.78562 Strange though, when they appear on web page, they are rounded and they become 0.70 My model class has this property as: public virtual decimal Rate { get; set; } Inside view code is: <td>@(Html.DisplayFor(m=>row.Rate))</td> Can you please guide why it is being round automatically and what I should do to stop this, I want to display what ever is real value. Much thanks

Calling a javascript variable inside a c# code

烈酒焚心 提交于 2019-12-23 04:33:18
问题 I have this Javascript function in my asp.net mvc4 with razor application function openbox2(formtitle, fadin) { var self = $(this); var arr = self.data('arr'); @{ Session["element"] = @:arr; } var box = document.getElementById('box'); document.getElementById('shadowing').style.display = 'block'; var btitle = document.getElementById('boxtitle'); btitle.innerHTML = formtitle; if (fadin) { gradient("box", 0); fadein("box"); } else { box.style.display = 'block'; } } html part code <td> <a href="#

How to display a collection in View of ASP.NET MVC Razor project?

丶灬走出姿态 提交于 2019-12-23 04:04:29
问题 How to display a collection in View of ASP.NET MVC Razor project? My Model and View is below. For one person i've to display Many tests on the screen. Thanks in Advance namespace UI.Models { public class SuperStudent { public string FullName { get; set; } public ICollection<TestDetail> CandidateTestDetails { get; set; } } public class TestDetail { public DateTime TestDate { get; set; } public string RegNum { get; set; } } } View @model IEnumerable<UI.Models.SuperStudent> <p> @Html.ActionLink(

Locate Razor Pages in another assembly

泄露秘密 提交于 2019-12-23 03:44:10
问题 I want to locate My Project Razor Pages in another assembly. for doing this I write following code: public void ConfigureServices(IServiceCollection services) { var adminAssembly = Assembly.Load(new AssemblyName("App")); services.AddMvc().AddApplicationPart(adminAssembly).AddRazorOptions(options => { var previous = options.CompilationCallback; options.CompilationCallback = context => { previous?.Invoke(context); context.Compilation = context.Compilation.AddReferences( MetadataReference

How to write an MVC3 Project Template that will offer option Razor or .aspx views

亡梦爱人 提交于 2019-12-23 03:33:17
问题 I have written two separate project templates to create MVC3 projects (both based on the standard Microsoft template, but with additional controllers/views of my own) - one with ASPX views, and the other with Razor views. But, rather than have two separate templates, I would rather mimic the way that the Microsoft MVC3 template works, which offers both view engine options, selected in a second dialog. I know that this is done with a Wizard, but I can't find the Wizard in the MVC source code

JS file/function referenced in _Layout.cshtml is not working on another Views

99封情书 提交于 2019-12-23 03:30:23
问题 I have some validation related functions that will be used on all my views and are located in an external JS file. I have added the JS reference in the _Layout.cshtml. My understanding is that if file is referred into _Layout.cshtml, then it would be available for usage in the Views rendered in the layout. However, when I ran some another view for example and inspected it, I see the reference to the JS file "val.js" but it results with an error in the console (probably that error was a reason

Get variables in PartialView

♀尐吖头ヾ 提交于 2019-12-23 03:22:28
问题 Say I pass data to a partial view like this @Html.Partial("_LandingPage_CaseStudiesList", new { TrackAction = "Case Study Click", CaseStudies = Model.CaseStudies }) How do I then get the data in the partial? I have tried Model["TrackAction"] and Model.TrackAction but neither work and I don't know what else to try. If I debug into the code I can see the properties but just don't know what to use to get them back Here is my partial <ul id="case-studies-list" class="table"> @{ int counter = 1;

Dynamic images and formatting parameters with @Ajax.ActionLink

喜你入骨 提交于 2019-12-23 03:16:12
问题 I’m trying to change the following working code into Ajax. <a href="@Url.Action("Index", new { pn = pc })"> <img src="@Url.Content("~/Photos/" + @photoFile[pc])", id = "imgnb" width = "100px" height = "150px" alt = "Photo" /></a> <br /> The code needs to handle a string[] variable, @photoFile[pc]), and take formatting, ( id = "imgnb" width = "100px" height = "150px" alt = "Photo"). (imgnb is css, no image border) Soe Moe built an Ajax helper here Problem with ajax.actionlink helper, return

Dynamic images and formatting parameters with @Ajax.ActionLink

最后都变了- 提交于 2019-12-23 03:16:00
问题 I’m trying to change the following working code into Ajax. <a href="@Url.Action("Index", new { pn = pc })"> <img src="@Url.Content("~/Photos/" + @photoFile[pc])", id = "imgnb" width = "100px" height = "150px" alt = "Photo" /></a> <br /> The code needs to handle a string[] variable, @photoFile[pc]), and take formatting, ( id = "imgnb" width = "100px" height = "150px" alt = "Photo"). (imgnb is css, no image border) Soe Moe built an Ajax helper here Problem with ajax.actionlink helper, return