htmlhelper

JavaScriptSerializer to serialize a javascript function name

Hello, I am using Flexigrid in my project to add a button on the grid toolbar I can use code like this: ... "buttons":[ {"name":"Modifica","bclass":"edit","onpress":"doCommand"}, {"name":"Elimina","bclass":"delete","onpress":"doCommand"} ], ... Anyway the "onpress" attribute shall contain a reference to a js callback and ...

How to create a fluent style MVC 2 Html.Helper?

Hi! Could someone point me in the right direction on how would I go about creating htmlhelpers that you could call in the view something like the code below. <% using (Html.BeginSvg()) {%> <% using (Html.BeginGroup("Group1")) {%> <%= Html.SvgLine("Line1").Class("blueLine").Style("stroke-width:2px").X1(25).Y1(25).X2(25)....

Using the Description Metadata Attribute in ASP.NET MVC

I am working on a VB.NET project which is using ASP.NET MVC 2. I am taking advantage of the ability to add validation and other attributes to the metadata in my model. For example, I have added attributes such as <DisplayName("Full Name")> to the properties in my model and am rendering these using the Html.LabelFor () extension method....

mvc.net how to use strongly typed helpers while iterating through list

I have a partial view that renders a list of objects into a table format and allows editing of the values... <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IList<whoozit.Models.PictureModel>>" %> <% foreach (whoozit.Models.PictureModel p in Model) { %> <td> <%: Html.TextBox("name",p.name) %> <%: Ht...

Html.Action asp.net mvc

Hi Experts, I am working on a website (Asp.net mvc), where I have multiple partial views. One of the views is user information and then below there are few other views say books by the user, articles in a given book etc. thats how my controller looks like. public class UserController : Controller { public ActionResult UserInfo(lon...

DateTime field and Html.TextBoxFor() helper. How to use it correctly?

Hi, I have a DateTime field in my Model. If I try to use this field in a strong typed partial view this way <%= Html.TextBoxFor(model => model.DataUdienza.ToString("dd/MM/yyyy"), new { style = "width: 120px" }) %> I will get the following compilation error at runtime System.InvalidOperationException : Templates can be used only wit...

.net mvc4 view / c# anonymous type and object htmlAttributes: new {class="mycssclass"} error

Ok, I cant find the answer to this: <%: Html.ActionLink("Click Here", "Action", null, new {class="myClass"})%> I want to set the CSS class attribute of the generated element. Obviously, C# will not allow me to use "class" as the name of an object's member. What should I do? ...

Get value from ASP.NET MVC Lambda Expression

Hi, I am trying to create my own HTML Helper which takes in an expression (similar to the built-in LabelFor<> helper. I have found examples to obtain the value of a property when the expression is similar to this: model => model.Forename However, in some of my models, I want to obtain properties in child elements, e.g. model => mode....

Hidden layer youtube video, on visible not loading IE7

hi, I have a html page. Which has few tabs (jquery). One of the hidden tab has youtube video. On the tab gets visible, the youtube video loads in IE8 and FF 3.6. But on IE7 it tries to load, but disappears. Please help me out to solve this problem. Thanks in advance. ...

What does Html.HiddenFor do?

Although I have read the documentation on Html.HiddenFor, I've not grasped what is it used for... Could somebody explain its uses and give a short example? Where should those helpers go in the code? ...

Get DisplayName Attribute without using LabelFor Helper in asp.net MVC

What is the best way to retrieve the display name attribute for an item in your model? I see a lot of people using the LabelFor helper for everything, but a label isn't appropriate if I just want to list the data out. Is there an easy way just get the Name Attribute if I just want to print it out in, say a paragraph? ...

default page error in HTML help work shop

When I open the help (/chm) application, I could see table of contents. By default, first entry in the file is selected ,however I couldn't see the corresponding page data instead I am able to see "This program cannot display the web page"(default error message that comes in IE7).The page is displayed only when I click on any of the cont...

Recursive unordered list from the inside and out

I'm trying to build a treeview HtmlHelper that builds an unordered list from the inside and out and show the children of the current node and the children of each parent. Has anyone done anything like this before or can give me some hints how i should solve it? ...

Replace Ajax.ActionLink output to use Jquery

Is there an easy way of replacing the generated output of Helper function Ajax.ActionLink to use Jquery instead of MS ? Or must i do all the job in a custom Extension? Someone must have done this EDIT: I think i'm looking at replacing the MicrosoftMVCAjax.js with something done with JQuery. Something called JQueryMVCAjax perhaps... ...

.net mvc2 custom HtmlHelper extension unit testing

My goal is to be able to unit test some custom HtmlHelper extensions - which use RenderPartial internally. http://ox.no/posts/mocking-htmlhelper-in-asp-net-mvc-2-and-3-using-moq I've tried using the method above to mock the HtmlHelper. However, I'm running into Null value exceptions. "Parameter name: view" Anyone have any idea?? Tha...

Is there any way to combine the output of two IHtmlStrings into a single IHtmlString instance?

I'm writing an ASP.NET MVC Html Helper which basically takes 2 HTML Helpers that return IHtmlStrings and combines them together and also returns them as an IHtmlString like so: //this doesn't work public static IHtmlString CompositeHelper(this HtmlHelper helper, string data) { //GetOutput returns an IHtmlString var output1 = new...

HTML batch save into folder - Any ideas ?

I am trasferring some old 'inhouse' html sites to a new system. The current folder structure is that all htmls of all sites are in one folder, and all the images of all those site are in /images folder. Ofcourse i need to have seperate folders for each html and its images. Just before writing some code to do the Job : Is anyone famil...

ASP.Net MVC: Html.Display() for object in a Collection

The standard MVC example to draw an item with the appropriate View Template is: Html.DisplayFor(m => m.Date) If the Model object has a property named Date of type DateTime, this returns a string with the HTML from the Display/DateTime.ascx template. Suppose you wanted to do the same thing, but couldn't use the strongly-typed version -...

How can I use Html.TextAreaFor() methods in my custom HtmlHelper?

I'm building an ASP.NET MVC 2 website and right now, I have ugly spaghetti code in my view which I would like to make into a custom HtmlHelper. The current code in the view is : <%switch (Model.fiFieldTypeID) %> <% { case 1: // Text area Response.Write(Html.Encode(H...

Asp.net MVC Html.Renderpartial Problem

Well I have this page < %@ .............. Inherits="System.Web.Mvc.ViewPage < Something.Models.SomeModel >" %> < % Html.RenderPartial("SomeControl",Model);% > and this user control page < %@ Control Language="C#" Inherits="System.Web.Mvc.ViewPage < Something.Models.SomeModel>"%> < p>< %: Html.TextBox("text",Model.Name) %>< /p> an...