htmlhelper

How do I use a spark variable in an html helper?

Can I use a spark variable inside an html helper? Say we have <var url="Url.Action(“get”)" /> !{Html.Image("~/Content/up.png")} Now if I need to use the url inside Html.Image as an attribute(part of the 2nd param) to get <img src="~/Content/up.png" type="~/engine/get" /> how do I go about doing it? ...

Ambiguous call between methods ASP.NET MVC

I'm pretty new in ASP.NET MVC (about 3 months) and i've the followin issue: I have a Entity Class called 'Usuario' in a ClassLibrary referenced as 'Core' and, when i create a strongly-typed view and add a html.textboxfor<> like: <%= Html.TextBoxFor(u => u.Login) %> it raises the following error: Error 3 The call is ambiguous bet...

ASP.NET MVC Html Helper Extensions and Rendering Their Required "include"s

I have build a custom Html Helper extension as follows: public static string DatePicker(this HtmlHelper helper, string name, string value) { return string.Format(@"<script type='text/javascript'> $(document).ready(function(){{ $('#{0}').datepicker({{ changeMonth: true, changeYear:true, dateFormat: ...

ASPNET MVC - Override Html.TextBoxFor(model.property) with a new helper with same signature?

I want to override Html.TextBoxFor() with my own helper that has the exact same signature (but a different namespace of course) - is this possible, and if so, how? The reason for this is that I have 100+ views in an already existing app, and I want to change the behaviour of TextBoxFor so that it outputs a maxLength=n attribute if the p...

cakephp links not relative

In my layout, I have a menu that I've included as an element, and it contains a link like so.. <? $html->link('New Part Number','/part_numbers/add'); ?> The problem that I have is that cake isn't redirecting correctly and it ends up sending me to "http://localhost/part_numbers/add" instead of "http://localhost/my_client_folder/client_...

Add onblur event to ASP.Net MVC's Html.TextBox

What's the correct syntax for an HTML helper (in MVC2) to define an onblur handler where the textbox is generated with code like: <%=Html.TextBox( "ChooseOptions.AddCount" + order.ID, (order.Count > 0) ? AddCount.ToString() : "", new { @class = "{number: true} small-input" } ) thx ...

ASP.NET MVC2 Radio Button generates duplicate HTML id-s

Hi, It seems that the default ASP.NET MVC2 Html helper generates duplicate HTML IDs when using code like this (EditorTemplates/UserType.ascx): <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<UserType>" %> <%: Html.RadioButton("", UserType.Primary, Model == UserType.Primary) %> <%: Html.RadioButton("", UserType.Stand...

Call asp.net mvc Html Helper within custom html helper with expression parameter

I am trying to write an html helper extension within the asp.net mvc framework. public static MvcHtmlString PlatformNumericTextBoxFor<TModel>(this HtmlHelper instance, TModel model, Expression<Func<TModel,double>> selector) where TModel : TableServiceEntity { var viewModel = new PlatformNumericTextBox(); var...

How to transfer value from a DropDownList to a property of a serialized model object

Hello, I'm testing some concepts in ASP.NET MVC multisteps (Style Wizards) with a small application which allow me to records organizations in a database. To make things easier, I've a class OrganizationFormModelView that contains an object of class Organization and a property called ParentOrgList of SelectList type. The only purpose o...

How do I control the DisplayForModel method in ASP.NET MVC 2?

If I use DisplayForModel in a strongly-typed ASP.NET MVC 2 View with an EntityObject model, then unwanted field labels are displayed: EntityState EntityKey How can I control the output to hide these? ...

Html.ListBox() and MultiselectList

Hi guys, I've a little problem with an Html.ListBox. I am developing a personal blog in ASP.NET MVC 1.0 and I created an adminpanel where I can add and edit a post! During this two operations, I can add also tags. I think of use an Html.ListBox() helper to list all tags, and so I can select multiple tags to add in a post! The problem ...

What is the easiest way to get the property value from a passed lambda expression in an extension method for HtmlHelper?

I am writing a dirty little extension method for HtmlHelper so that I can say something like HtmlHelper.WysiwygFor(lambda) and display the CKEditor. I have this working currently but it seems a bit more cumbersome than I would prefer. I am hoping that there is a more straight forward way of doing this. Here is what I have so far. pub...

asp.net mvc model binding

I am using asp.net mvc to do model binding. When I pass a model to a view I am able to see the model data displayed in the form inside a label <%= Html.Label(Model.title) %> <%= Html.Label(Model.description) %> However I am not able to do the same using <%= Html.TextArea(Model.description)%> Is there a syntax difference betwe...

Asp.Net MVC 2 Html.TextBoxFor Best way to specify a format string for a DateTime property of model

As the question title explains, what is the best way to specify a format which my Views use when displaying values of a DateTime property via the Html.TextboxFor method. The default display includes the Date and Time where I really only want the Date displayed. Thanks ...

Making a Lambda Expression Target a Delegate regardless of signature

Ok, maybe the title isn't the most descriptive thing in the world, but this problem is killing me. What I'm trying to do is create an ActionLinkFor helper method, like so: public ActionResult Index() { // Does Stuff } public ActionResult SomeAction(int param1) { // Does Stuff } These are two action methods. Action methods can h...

How to disable radiobuttons and checkboxes produced by HtmlHelper methods in ASP.NET MVC?

Hello, I have a series of pages (in a wizard type application). After collecting user's inputs here and there, I'd like to display a summary in a single page. I don't want the users to modify information on that page, just to visualize them. Otherwise, he they go back to the prevoius pages to do so. To obtain that, I use Html.Encode(Mo...

How do i set focus to a text box Html.TextBoxFor - mvc 2

Hi, I'm trying to set focus on a text box which generated in the following way: <%=Html.TextBoxFor(model => model.Email, new { style = "width:190px;Border:0px", maxsize = 190 })%> i tried to use javascript which didnt help much. var txtBox = document.getElementById("Email"); if (txtBox != null) txtBox.focus(); ...

How to use rich text in htmlhelpers or use html and links in asp.net mvc 2?

Hi all I wanted to allow the users to enter html and links in textbox. How can I achieve something like this in ASP.NET MVC 2? I have something like this now... <div class="editor-field"> <%= Html.TextAreaFor(model => model.Description) %> <%= Html.ValidationMessageFor(model => model.Description) %> </di...

Rails form helper and RESTful routes

Hey guys, I have a form partial current setup like this to make new blog posts <% form_for([@current_user, @post]) do |f| %> This works great when editing a post, but when creating a new post I get the following error: undefined method `user_posts_path' for #<ActionView::Base:0x6158104> My routes are setup as follows: map.resour...

What's wrong with my HtmlHelper?

I've created an Html extension method in Helper class, but I can not get it to work. I've implemented it as seen on different tutorials. My MenuItemHelper static class: public static string MenuItem(this HtmlHelper helper, string linkText, string actionName, string controllerName) { var currentControllerName = (string)help...