I'm using Url.IsLocalUrl to check if the return URL passed to my authentication action is local or not. It works fine as long as there is no fragment in the URL. That is,
/t/test-team-3/tasks/lists/15 returns true, but /t/test-team-3/tasks#/lists/15…
A controller in my ASP.NET MVC application pre-populates form data displayed by my view according to a couple of fairly straight forward rules.
It seems like this would be a good thing to cover in my unit testing. But the only way I could see to…
How can I set a value to my model using jQuery?
I have an input field (which its id="comment") and I want the text in it to be inserted into @Model.Comment
using jQuery.
something like: @Model.Comment = $("#comment").val();
I am trying to implement a validation strategy in my application. I have an MVC layer, Service layer, Repository and Domain POCOs. Now at the MVC layer, i use data annotations on my viewmodels to validate user input, allowing me to give the user…
I have seen this useful answer to a question for adding constants into a javascript file so it can be used with razor views: Share constants between C# and Javascript in MVC Razor
I'd like to be able to do the same except define enums, but I'm not…
I have an Extension Method that verifies if the user is able to see a portion of the webpage, based on a Role.
If I simple remove the content, this brings me more work as all the missing forms will not be correctly registered upon save and I have to…
I have a simple user registration form, with two fields, one for username and another for the password. I have a controller called UserController which has these two actions:
[HttpGet]
public ActionResult Register()
{
return…
My update method is not working in an ASP.NET MVC 3 application. I have used the following EF 4.1 code:
[HttpPost]
public ActionResult UpdateAccountDetails(Account account)
{
if (ModelState.IsValid)
{
service.SaveAccount(account);
…
i'm trying to concatenate a string in asp.net mvc 3 razor and i'm getting a little sintax problem with my cshtml.
i what to generate an id for my checkboxes on a foreach statement, and my checkboxes should start with "chk" and what to cancatenate a…
I have got two models, seen below, and am trying to insert one of each to the database from one view. I have created a view model in an attempt to do this.
public class Blog
{
public int BlogID { get; set; }
public string Title { get; set;…
I have an ASP.NET-MVC3-Layout and use the RenderSection function:
@RenderSection("BackLink", required: false)
How can I call this function twice? I want to render a defined section at multiple places in my layout.
If I use @RenderSection() more…
I'm trying to set id and name for @Html.EditorFor, but this isn't working:
@Html.EditorFor(model => model.value, new { @id = "testid1", @name="testname1"})
How do I set id and name?
As I understand from the question below it should be possible to use different models for Get and Post actions. But somehow I'm failing to achieve just that.
What am I missing?
Related question: Using two different Models in controller action for…