Is there a clean way to manage my Asp.Net Mvc Web site to both work correctly if javascript is enabled/disabled. Because, for now, I have to do hack like that to make both work. I think that doesn't make code that is easy maintainable and reusable...
if (Request.IsAjaxRequest())
{
return PartialView("SignUpF...
I can have a base class for views in an MVC project like this:
public class BaseViewPage : System.Web.Mvc.ViewPage
{
public string Something { get; set; }
}
And then in the ASPX I can do this:
<%@ Page Something="foo" Language="C#" Inherits="MyNamespace.BaseViewPage" %>
This works fine; the problem is when I try to do the same wi...
When I validate a form with Asp.Net Mvc and there's an error on the form, Asp.Net return me the form with the correct error message but clear the content of the input. I would like the content of the input to stay even if this content is wrong. How can I do that ?
UPDATE
Maybe this is because I don't use the default validation. I use t...
So I have this ascx (partialView) control - ControlTemp
I have an ajax.BeginForm inside ControlTemp like this:
<% using (Ajax.BeginForm("ControlTemp", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "divControlTemp" })) {
....
<input type = "submit" />
<%}%>
Inside my masterpage, I am using this pa...
Usually I protect my Actions with [Authorize] but this time I need to check if a user is authorized inside the action.
Eg
if(userIsAuthorized) {
//do stuff
}
else {
//return to login page
}
I believe I am using 'Forms Authentication'
This question is kind of similar to this but none of the answers given seemed to work.
EDIT...
Hi
I always heard the benefit of making html helpers but no one really shows how it would look if you did not right an html helper.
So I just wanted to write a label with plan html and not my html helper I made
<label for="<% ViewData["View_CoursePrefix"].ToString(); %>"></label>
I am trying to put a viewData in the "for" part but i...
Simple question. I must be totally wrong but I thought worth asking this question.
Is accessing ViewData[“Message”] within the View correct according to separation of concerns described in MVC?
For example, in Controller:
ViewData[“Message”] = “Display this message”;
Within View we call
<%= ViewData[“Message”] %>
The alternativ...
I want to write a action method returning Javascript.
How to run javascript using MVC controller?
I tried the following, but it fails to work properly. It shows file download - security warning?
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult About(clsABC param)
{
string message = "Hello! World.";
System.Text.St...
This is a fairly recurring theme on StackOverflow, but once again I can't get my MVC controller action to recognise the data I'm trying to send. Any suggestions gratefully received.
My controller action looks like this:
[Authorize]
[HttpPost]
public JsonResult Record(int task, string notes, double hours)
...
Every article found in the Internet on using ViewModels and utilizing Automapper gives the guidelines of the "Controller -> View" direction mapping. You take a domain model along with all Select Lists into one specialized ViewModel and pass it to the view. That's clear and fine.
The view has a form, and eventually we are in the POST act...
Hi,
I am developing an MVC application.
I want to call a javascript function on page load event of a page.
Also I want to pass some string parameters to this function which i want to show as confirm message content. On confirm's OK click, i want to show an alert.
How can i do this?
Thanks,
Kapil
...
How to check whether the browser supports javascript?
I need to redirect the users to a Notification Page, if the user's browser don't support javascript. How can i do this in my asp.net mvc(C#) application?
Whats the best way to handle this in asp.net mvc?
The html i tested:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://...
I’m having problems with the AntiForgeryToken in ASP.Net MVC. If I do an iisreset on my web server and a user continues with their session they get bounced to a login page. Not terrible but then the AntiForgery token blows up and the only way to get going again is to blow away the cookie on the browser.
With the beta version of versio...
Hello,
I'm new to MSpec and would like to know if the way I wrote my test for ASP.NET MVC is correct. The test passes but I don't really like the way it's written and it seems awkward. I'm certainly missing something.
public class AccountControllerTests3
{
protected static AccountController controller;
static IFormsAuthenticati...
As an Asp.Net MVC developer, what is the best starting point to dive into WPF?
...
Hi all,
Can anyone please tell me about -
How can i handle Html.DropDown control's events in MVC View?
Can I handle it using scripts?
And how to know about the selected item?
Thanks,
kapil
...
I just got pinged on another post because my application doesn't keep the user logged in after an iisreset.
http://stackoverflow.com/questions/2206595/how-do-i-solve-an-antiforgerytoken-exception-that-occurs-after-an-iisreset-in-my/2206609#2206609
I have to say I agree with the commenter that it is an artificial restriction.
From what...
Is it possible to add "empty" query string parameters with ASP.NET MVC? I need to somehow generate the following url using Html.ActionLink:
/Home/Index?foo
However this Html.ActionLink("Index", "Index", new {foo = ""}) will output
/Home/Index
Is this possible at all?
...
Hi Guys,
I'm working on a project where certain logged in users have a dedicated page which they can choose the url of. When a user logins in i would like to display a link "View my page". I was just wondering what is the best way to store this baring in mind it needs to be accessible for as long as the user is logged in (The site has a...
Hi,
I have a website that was originally written in webforms to which I have added MVC functionality. When debugging locally it works fine, however, once published and uploaded to my host the routes do not work and return a 404.
I am pretty sure that I have uploaded all the correct files. Would just appear that routing is not working.
A...