I am following a simple ADO.NET Entity/MVC 2 tutorial wherein my Views are created by right-clicking the action and selecting 'Add View'. The views get created based on my model and all is good. I can view the initial list of items from the DB but when I click Edit or Delete or Details I get 'Object reference not set to an instance of an...
I'm looking for an elegant pattern to solve this problem:
I have several user roles in my system, and for many of my controller actions, I need to deal with slightly different data.
For example, take
/Users/Edit/1
This allows a Moderator to edit a users email address, but Administrators to edit a user's email address and password.
...
I build a drop down list in my aspx page as following
<%= Html.DropDownList("SelectedRole", new SelectList((IEnumerable)Model.roles, "RoleId", "RoleName", Model.SelectedRole), "")%>
it works fine for first Get and the first default value is selected; then I select item from the drop down list and submit the form.
the controller bind ...
I've got a controller action that returns a FileResult like this
return this.File("file.pdf", "application/pdf");
for the URL "/Download/322" - where 322 is the id of the file.
This works great, so that if a user clicks on a link to the PDF - it will open in their web browser as long as they have a PDF plugin installed.
But, what if...
I need to send some other data, ideally wrapped in a JSON object, down to the client. As well as that however I need to send a Partial view. Now I can only think of two ways:
Send JSON object and then make another call to load contents of partial view into div.
Send HTML for Partial View as a property of the JSON object and then load i...
My question is similar to "ASP.NET 2 projects to share same files", but with an ASP.NET MVC slant.
Basically, we have two sites, one being based mostly on the other (roughly 90% views, controllers, images, in the second are identical to the first). However, in some cases, the views may be different, or a controller in the second site ma...
I have created a ViewUserControl in my ASP.NET MVC 2 project. This ViewUserControl serves as the general page-header for all views in the project.
How can I add a custom property on ViewUserControls, accessible from views using that control?..:
<%@ Register
Src="../Shared/Header.ascx"
TagName="Header"
TagPrefix="uc" %>
<uc...
I am trying to figure out how to correctly and efficiently unit test my Asp.net MVC project. When I started on this project I bought the Pro ASP.Net MVC, and with that book I learned about TDD and unit testing. After seeing the examples, and the fact that I work as a software engineer in QA in my current company, I was amazed at how aw...
I am using Yahoo Editor for my asp.net mvc (C#) application.
When i tried to use the iframe, its ripping of the complete html. It works in Chrome, but not in Firefox and IE.
I have tried pasting the below html in http://developer.yahoo.com/yui/examples/editor/code_editor.html.
<iframe src="http://www.google.com" width="100%" height="3...
I am trying to use jquery validator plugin and form submit via ajax in jquery.....
Validator plugin works with <input type="submit" value="Add a client" id="clientadd"/> but my form submit works with <input type="button" value="Add a client" id="clientadd"/>.....
<form id="addform" autocomplete="off">
//My controls here
</form>
I di...
I've been an ASP.NET developer for some time, always working on existing ASP.NET pages, modifying functionality, adding features, tweaking things etc. but have never built a site up from scratch. I've read books on ASP.NET, and they generally talk you through the various features of ASP.NET with a mock up site, but it's always very basic...
Short question is:
how can i use graph api oauth redirects mechanism to authenticate user and save retrieved access_token and also use javascript SDK when needed (the problem is javascript SDK will have different access_token when initialized).
I have initially setup my facebook iframe canvas app, with single sign on. This works well wi...
If I am creating a website in ASP.NET, is it possible to programmatically set the title of the page be some predefined value with some extra information tacked on? For example:
Home Page Title = Site Name
Links Title = Site Name: Links
Stuff Title = Site Name: Stuff
Basically, whatever I defined as the main title on ...
I have a partial view called StudentInfo.ascx. In it I have something like this:
<fieldset>
<legend>Students Information</legend>
<div>
<label>First Name:</label>
<label>Last Name:</label>
</div>
</fieldset>
I have another partial view called Detail.ascx which will need to display this StudentInfo.ascx. I did somethin...
Since HandleError is inherited by the derived Controllers, why wouldn't I just create (or have) a base controller, and apply HandleError on it so that any controllers that inherits from the base controller will automatically be handled as well?
And then I would tack on overriding HandleError on controllers and individual actions.
Can a...
I am trying to share sessions between two web applications, both hosted on the same server. One is a .net 2.0 web forms application the other is as .net 3.5 MVC2 application.
Both apps have their session set up like this:
<sessionState
mode="StateServer"
stateConnectionString="tcpip=127.0.0.1:42424"
/>
In the webfo...
Hi! I have a login page with an input of type "password" I would like to have a virtual keyboard to enter the password. I've searched and I found the jquery script for virtual keyboard. The code said to add this to my page
$('input[type=password]').keyboard({
layout: "qwerty",
customLayout:
[["q w e r t y {bk...
I'm getting some weird behavior in asp.net MVC2 (at least it's not what I'm expecting). I have a controller httppost action that processes credit cards. I'm setting a session variable on the server to let me know if a user has attempted to process a card. I clear that session variable when I'm done. I am doing some very quick posts t...
When I look at ASP.NET MVC projects I everytime see loose coupled architecture.
For what do I need a loose coupling in a web architecture (if I do not make unit tests)?
What are advantages and disadvantages of this?
...
Hello (this is a long post sorry),
I am writing a application in ASP.NET MVC 2 and I have reached a point where I am receiving this error when I connect remotely to my Server.
Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user ...