htmlhelper

Setting Value Html Attribute For Html.TextBox (MVC 1.0)

I'm creating an Html TextBox via HtmlHelper and I can't get the value attribute set. I've tried both of the lines below and I have also googled but cannot find a solution: <%= Html.TextBox("name", null, new { @class = "textbox", value = "hi" }) %> <%= Html.TextBox("name", null, new { @class = "textbox", @value = "hi" }) %> Both lines ...

CakePHP: image inside link, want to make link point to image location

I have some images inside links that I want to essentially look like this: <a href="/path/to/img.png"><img src="/path/to/img.png" /></a> Clicking on the link should load the image it contains. I'm trying to use CakePHP's HTML helper to do this, as follows: <?php echo $html->link( $html->image('img.png'), 'img.png', arra...

Rendering partial views with a model and htmlhelper

ASP .NET MVC 1 I'd like to show a partial view base on a model, and I'd like that to have a fairly short command for that. So I saw a way of using both a HtmlHelper and a controller (And I'd use another controller for that, not the controller currently used). But somehow it still gives an error, though I think the method starts to look...

Unit Testing An Extension Method on HtmlHelper

I have an HTMLHelper extension method that outputs HTML to Response.Write. How best to unit test this? I'm considering mocking the HtmlHelper passed into the method, but am unsure as to how I should verify the HTML sent to Response.Write. Thanks ...

How do I use the ASP.NET MVC ValidationMessage HTML Helper inside my own custom helper?

Hi, I am trying to create a custom HTML Helper that encapsulates some presentation logic because I have to reuse this logic a few times on the same page and maybe in the future. If the user's address is in North America, then I want two text boxes to be displayed for the telephone number input, one for the area code and the other for t...

ASP.NET MVC Html.Element ?

Is there a generic Html.Element? I would like to be able to do this: Html.Element<AccountController>("IFrame", "elementName", new { src = c => c.ChangePassword }) ...

Where to put my custom Html Helpers ?

Where to put the helper class in the project folder hierarchy ? ...

Html Helper Not Working on nested Site Master page

I'm sure I'm doing something really stupid, but I've created a Nested Site master for one section of my app. I got the extra text to show up, like it should on the new Site Master (Greek.Master). But when I went to add some Html to Greek.Master, I found out the html helper isn't working. Here's my nested master <%@ Master Language="C...

Given htmlHelper + action name, how to figure out controller name?

How does HtmlHelper.ActionLink(htmlhelper,string linktext,string action) figures out correct route? If i have this=> HtmlHelper.ActionLink("Edit","Edit") Mvc automatically finds out correct route. i.e. - if controller was Product, it will render anchor with href product/edit. So - how to figure out controller name when i got htmlHe...

Location of HtmlHelper instantiation for ASP.NET MVC

I am trying to debug a problem where HtmlHelper is null in extension methods. Oddly the debugger claims it's fully populated, however I consistently get null exceptions. I'm trying to figure out where HtmlHelper should being instantiated in an attempt to see where my problem may be. Where should HtmlHelper be Instantiated? Update: I...

ASP.NET MVC: Hidden field value does not get rendered using HtmlHelper.Hidden

Hey, Something pretty weird is happening with my app: I have the following property in my ViewModel: public int? StakeholderId { get; set; } It gets rendered in a partial view as follows: <%= Html.Hidden("StakeholderId", Model.StakeholderId) %> The form is submitted, and the relevant controller action generates an id and updates ...

Strongly typed htmlhelper & spark

I read that it's possible, but didn't get idea how. Any ideas? ...

Solution for category tree with less query?

Basically, the Model is like this: ---------------------------------- | CAT_ID | CAT_NAME | CAT_PARENT | ---------------------------------- which make this a recursive relationship. But how should we use this model in our Asp.net mvc web application with least amount of query. My temporary solution is pass the object in to the functi...

Best way to hide Table or Grid and display No Records Found Message with ASP.NET MVC ?

Hi, What is the best practices for hiding a custom grid or a table or a div and display a "No Records Found" message when there are no records. I ve come up with this idea <div class="<%= Html.IsVisible(Model.Count)"> ... .. .. </div .displayNone {display:none;} .displayInherit {display:inherit;} public static str...

Html.DeleteActionLink helper

Hi all, I have a link to delete action using Jquery dialog confirm message. Clicking on delete link, a modal popup is showing with a confirmation question. Button Yes is triggered to submit the form with id = Model.Id <td> <% using (Html.BeginForm<AssessorActionPlanController>( c => c.Delete(Model.Id), FormMethod.Post, n...

MVC Html Helper Rendering

Hi, I was wondering if it's possible to render an Html Helper in a View inside a codeblock. So instead of: <% = Html.TextBox("sometextbox", "somethingelse") %> I want to do: <% switch(SomeParameter) { case "blah": Html.TextBox("sometextbox", "somethingelse") break; } %> And have this render. Of course as it is, it ...

ActionLink helper problem

Hi all I am trying to get through Rob Conery tutorial MVC StoreFront ans I have a problem with a line of code which is a link to a controller action. <div class="categoryNavigation"> <% foreach (Category parent in ViewData.Model) { %> <h3><%=parent.Name%></h3> <ul> <%foreach (Category child in paren...

Is it possible to create a custom ASP.NET MVC strongly typed HTML Helper?

Hello, I was wondering if it is possible to create a custom strongly typed HTML Helper in ASP.NET MVC 2? Creating a regular (read not-strongly-typed) helper is straightforward but i am having difficulty creating strongly typed versions. For example, I would like to create a DatePickerFor html helper... Any guidance or snippets would be ...

How can I use an HTML page as an email that reads as such in mail servers exactly as seen on the web?

I prepared an email that would look interesting, and tried to send it by using Safari. The setup did not come out in the emails the way it looks at the web page. In some web clients only the blue background came out, in others there was no background and the three columns were set one after the other, with the center one last. In other w...

Are there any built in helper methods to display enumerations in a dropdown?

I have enumerations that I need to display in a dropdownlist, and have them pre-populated in my admin pages. Are there any built in html helpers for this already? (asp.net mvc) ...