asp.net-mvc

jqGrid 'url' parameter causes errors in pages in deeper URLs

I'm trying to deploy an ASP.NET MVC site to a Windows 2003, IIS 6.0 server with the 3.5 framework installed (but not ASP.NET MVC - it's just in the bin folder). The site makes use of jqGrid, but on the deployment server the grid is failing in certain cases. The web site's master page is at /Views/Shared/Site.Master. It has a script tag ...

Is it bad practice to make multiple, separate database calls from ASP.NET MVC web app?

I have a controller attribute called [RequiresCompletedProfile], that I can put on action methods to disallow a user from going there unless they have completed their profile. This was working fine when I had one kind of user, but the app has since evolved into having 2 kinds of users: Vendors and Clients. So, there is no longer a "Use...

Add OnClick Event to Html.RadioButton

What I want to do is to call a JavaScript routine when the user clicks on a radiobutton. I've some fields to enable/disable when this happens. However, when I enter <%=Html.RadioButton("obp17", "57", ViewData.Eval("obpValue17").ToString().Equals("57"), new {@onclick = "Yes()"})%> I'm getting a "type or with" expected error when tr...

Best Way to automatically compress and minimize JavaScript files in an ASP.NET MVC app

So I have an ASP.NET MVC app that references a number of javascript files in various places (in the site master and additional references in several views as well). I'd like to know if there is an automated way, and if so what is the recommended approach, for compressing and minimizing such references into a single .js file where poss...

How to stop an MVC RedirectToRouteResult JavaScript?

I am designing a site and am trying to be compatible with javascript turned off or on. I have a Controller Action named as follows... public RedirectToRouteResult AddWorkAssignment(int id) { // delegate the work to add the work assignment... return RedirectToAction("Index", "Assignment"); } and my jQuery I do a post $('#som...

How do you debug ASP.NET startup issues using the Development Server

I have created a new ASP.NET MVC project using the MVC Project Template. According to the book I am reading the ASP.NET MVC book I am reading (Pro ASP.NET MVC framework by APRESS) the application is supposed to just run out of the box using the Visual Studio Development Server. It DOES compile and run but IE returns a page load error.....

"Callbacks" in Linq-to-SQL/ASP.NET MVC

After using .NET for several years, I've spent the last few months in the far off land of Ruby on Rails. While I can clearly see where much of Microsoft's MVC framework got it's influence, one of the things that I find myself suddenly missing when development in .NET are the Rails Model callbacks. Specifically, you can add a callback t...

Validation detected dangerous client input - post from TinyMCE in asp.net

I get this error when i post from TinyMCE in an asp.net mvc view Error: Request Validation has detected a potentially dangerous client input value, and processing of the request has been aborted from googling, it says to just add a validateRequest in the Page directive at the top which i did but i STILL get this error. As you can see...

Setting properties on a mocked HttpContextBase

I'm working on an ASP.NET MVC application, and am trying to write some unit tests against controller actions, some of which manipulate properties on the HttpContext, such as Session, Request.Cookies, Response.Cookies, etc. I'm having some trouble figuring out how to "Arrange, Act, Assert"...I can see Arrange and Assert...but I'm having t...

Cannot retrieve user object from foreign key relationships using Linq to Entities statement

Hi, I'm trying to retrieve a user object from a foreign key reference but each time I try to do so nothing gets returned... My table is set up like this: FBUserID long, UserID uniqueidentifier so I have my repository try to get the User when it's provided the FBUserID: public User getUserByFBuid(long uid) { User...

What is ASP.NET MVC not good for?

I'm a big fan of what ASP.NET MVC is doing, on many levels. I'm about to take part in re-build of a very highly trafficked website, and I'm not which framework would be best (if any). The site will need the following: To support Javascript-heavy, highly interactive pages But at the same time, provide underlying semantic HTML for sear...

asp.net-mvc is it possible to get ViewData and stick it inside javascript function

i have the following javascript that gets HTML from somewhere and sticks it in a textarea for tinymce. My question is how in asp.net-mvc i can get the HTML Here and stick it in the javascript? Do i put this in ViewData? function ajaxLoad() { var ed = tinyMCE.get('elm1'); // Do you ajax call here, window.setTimeout ...

How to render the following asp.net mvc c# code snippet as vb.net code

Hello, Working through Pro ASP.NET MVC book and I got the following code snippet that appears in an aspx (view) page... <%= Html.DropDownList ("WillAttend",new[] { new SelectListItem { Text = "Yes, I'll be there",Value=bool.TrueString}, new SelectListItem { Text = "No, I can't come",Value=bool.FalseString} },"Choose an option"); %> ...

How to select an object through a foreign key

If I have a table with a primary key (AccLinkID) and a foreign key (aspnet_Users UserID), how can I select the object that the foreign key points to using Linq to Entities. User myUser = _myDB.AccLinkSet.Where(user => user.LinkID == linkId).FirstOrDefault().aspnet_Users; did not work... anyone have any ideas? ...

how to figure out if a facebook user is logged to facebook connect in from C#

I'm trying to figure how whether or not the current user is logged in with their facebook account on my site... I've tried searching around and looking through the facebook namespace but haven't found anything similar to isUserLoggedIn(). I'm guessing I missed it somewhere... Anyone know of a method that would work for this? ...

how to pass data from view to controller in asp.net mvc

What is the best way to pass random data from a view to a controller. I have a number of views that are identical except for a few pieces of state information. instead of creating a page for each webpage, I want to have one page and I just pass over these variables dynamically. ...

ASP.NET MVC website where users can add/remove pages

I'm developing a website for a client, in which they want to be able to manage content and add/remove pages. At the same time, some pages on the site will be interactive and provide custom reports for logged-in customers. I've started developing the site in ASP.NET MVC, because I wanted full control over rendering. However, I'm findin...

asp.net mvc adding validation causes Model to be null

i just about finished my first asp.net mvc site but i wasn't happy with the robustness of the validation. i read up on validation and then added the below code to my Edit action in my UsersController: if (user_.firstname.Trim().Length == 0) { ModelState.AddModelError("firstname", "First Name is required."); ...

keep viewdata on RedirectToAction

[AcceptVerbs(HttpVerbs.Post)] public ActionResult CreateUser([Bind(Exclude = "Id")] User user) { ... db.SubmitChanges(); ViewData["info"] = "The account has been created."; return RedirectToAction("Index", "Admin"); } This doesnt keep the "info" text in the viewdata after the redirectToAction. How would ...

Is there any way to have language independent controllers/views/actions

I'm coding some web-applications in MVC, and I have a problem with something that has been on my mind for a time. The web-aplications I'm developing are mostly going to be used in Swedish, and because of the language I want to have my URL routing mapped against Swedish URL names. mysite.com/products/details/1 (English URL) mysite.com/...