I am using a <% foreach ...%> loop to list a collection of items on my website.
I want to add a different background color for the style of alternating rows in my list. I have found a way to do this but I am not satisfied with it as it seems like a hack.
Here is what I have done to solve it so far:
<table>
<% int counter = 0;
...
Hi,
In rails you can do the following to convert an object to Json but only with a subset of the fields included in the object.
@user.to_json :only => [ :name, :phone ]
Although i am using currently the ASP.NET MVC Json() function it doesn't let me define which fields i want to include in the conversion. So my question is whether or ...
How to use System.Web.Mvc.SelectListItem for asp.net mvc controller.
...
Hello,
What is the best practice for validating my model for different actions, for example, different validation rules for creating and deleting?
Thanks!
Clarification: I think this needs some clarification because the answers don't seem to be addressing the question.
For example,
Create Person
Validates that has name, age and em...
We currently have a classic ASP.NET web application which serves as our API. It basically has a bunch of ASMX Web Services, but these are really cumbersome to work with from JavaScript. What I want is to expose a set of RESTful endpoints, but doing this in classis ASP.NET is not what I really want to do.
I'm considering to combine both...
I guess this is a noob question, but here it comes:
I have a list of products:
<% foreach (var item in Model) { %>
<tr>
<td>
<%= Html.Encode(item.code) %>
</td>
<td>
<%= Html.Encode(String.Format("{0:g}", item.date)) %>
</td>
<td>
<%= Html.Encode(item.cate...
How can I make routing for this?
URL: /category/main/sub/ or /category/main/sub1/subsub/
I want to have /main/sub/ and /main/sub1/subsub/ as parameters in Index action method of CategoryController.
...
I have some dropdowns shown in my asp.net mvc application with the same name (say: 5 dropdowns with the same name 'uniquedropdown'.)
I need to get all the selected values of the dropdowns with the same name using jquery.
How to get it?
...
I'm using .Net Open ID (http://code.google.com/p/dotnetopenid/)
I'm trying to add OpenId to a website we are using. I'm running the MVC sample out of the box and recieve the following error when selecting Yahoo/Google.
No OpenID endpoint found.
The error happens on this line of code
return openid.CreateRequest(Request.Form["open...
I use ajaxForm with jQuery, and there's one problem with Firefox - for some reason it does not preserve X-Requested-With custom header (which is used to detect IsAjaxRequest()). This leads to my controller action returning full view instead of partial since IsAjasxRequest() returns false after redirect.
This bug only happens in Firefox,...
I have the following situation assume i have to display the data in the follwing format.
I am 20 years old . i need the number 20 to be in bold.
I'm fetching this string from resoucre file like this
string.Format(HttpContext.GetGlobalResourceObject("ResourceFile","Key"),age);
should i consider adding the tags <b> and </b>
in the...
I've got a repository using LINQ for modelling the data that has a whole bunch of functions for getting data out. A very common way of getting data out is for things such as drop down lists. These drop down lists can vary. If we're creating something we usually have a drop down list with all entries of a certain type, which means I ne...
I have an ASP.NET MVC app with a form. Say this form has an arbitrary number of buttons, each with their own action.
<input type="button" id="action1" value="One" />
<input type="button" id="action2" value="Two" />
... and so forth
We want the user to click on one and have a jQuery action fire to submit the form and then repost the...
Hi,
I have a Create ActionMethod, something along the lines of:
[AcceptVerbs(HttpVerbs.Post)]
public ActionMethod Create(Journey journey)
{
if (Request.IsAjaxRequest())
{
//Save values
return Json(new { JourneyID = journey.JourneyID } );
}
}
The Journey object that I pass in is from my LINQ2SQL datamodel. I call the ab...
Hi all,
I've created a report using SQL Server Report Builder 2008.
I was wondering if there were any examples out there on how to have this run in an Asp.net MVC App. I figured that setting the datasource and streaming it directly to a pdf file would be do-able, but i keep getting the following error when LocalReports Render Method is...
Hi
I am trying to do PayPal IPN method. So I thought since I am doing asp.net mvc I can just make a method view in my controller like this
public void IPN()
{
// IPN code
}
So I tried this all on local host made my own form to post some IPN variable stuff and it worked fine. I uploaded it to my server and used the IPN simulator fro...
Hi
I am having a weird problem and I am not sure why.
I have this in my webconfig
<add key="SMTP" value="mail.reliablesite.net"/>
<add key="Email" value="Email"/>
<add key="EMAIL_PASSWORD" value="Password"/>
<add key="FROM_PORT" value="2525"/>
Now when I test smtp through localhost all is well and sends my smtp and eve...
How can I get the controller name of a relative Url, using the routes I have defined in Global.asax?
Example:
if I have a route defiend like this:
routes.MapRoute(
"Default", // Route name
"{language}/{controller}/{action}/{id}", // URL with ...
Given a url that follows the following pattern:
firstcolor={value1}/secondcolor={value2}
where value1 and value2 can vary and an action method like:
ProcessColors(string color1, string color2) in say a controller called ColorController.
I want the following route evaluation:
URL '/firstcolor=red' results in a call like ProcessColor...
My colleague is extremely 'hot' on properly formatted and indented html being delivered to the client browser. This is so that the page source is easily readable by a human.
Firstly, if I have a partial view that is used in a number of different areas in my site, should the rendering engine be automatically formatting the indentations f...