htmlhelper

Reusing ViewPage/HtmlHelper in seperate project in ASP.NET MVC using C#

I want to use the ViewPage/HtmlHelper class in the System.Web.Mvc namespace in a seperate project. I imported the relevant libraries and then tried this: using System.Web.Mvc; using System.Web.Mvc.Resources; using System.Web.Mvc.Html; public static class Display { public static string CheckBox() { ViewPage viewPage = n...

SelectedValue not binding for some of the Html.dropdownlist in asp.net mvc???

I got 3 html.dropdownlists out of which only for 1 its the setting the selectedvalue.How come its binding for one of the dropdownlist not for the other 2.In the Quick Watch,all the values are proper, it even shows which value has its selected=true. but in the page it doesnt get set. Is there any solution for this? Function Index(ByVal c...

.input-validation-error class not added to input in view

Hi Everyone, I am trying to add some simple validation to my asp.net mvc form and am having trouble getting the .input-validation-error class to be added to my inputs. The validation-summary-errors and .field-validation-error work fine. Thanks in advance for your help! Edit: Thanks for everyone's help!!! I had to add this line to t...

ASP.NET MVC html helpers not working

Hi Guys, I hope somebody can help me. I've been trying to write a custom html helper for my MVC application. First at all, i tried with a testing one, which only writes a tag for the specified param. The things is, it does not work unless I explicitly import the namespace. I've been reading a lot and as i read, That method should appear...

Generate URL in HTML helper

Normally in an ASP.NET view one could use the following function to obtain a URL (not an <a>): Url.Action("Action", "Controller"); However, I cannot find how to do it from a custom HTML helper. I have public class MyCustomHelper { public static string ExtensionMethod(this HtmlHelper helper) { } } The helper variable has t...

How should I make this? With an Table cell Html helper or some other way?

Hi I am using asp.net mvc and I am not sure how to approach this problem. I have a table in my database and that has some fields in it. I want to generate a table with this. So I first tried to make a html helper that would make the table and and all the stuff I need but I am finding it too hard to maintain and causing problem for the ...

What is the difference, if any, between string.Format and TagBuilder in ASP.NET MVC?

Hello SO: I have a Html Helper file for my ASP.NET MVC application. The majority of them simply return a formatted string. Here is an example of one of my formatted string helpers: public static string Label(this HtmlHelper helper, string @for, string text) { return string.Format("<label for \"{0}\">{1}</label>", @for, text); } ...

skip or disable links to current path in ASP.NET MVC

I'm writing an helper that basically receives many RouteValueDictionary and returns many links; I'd like to skip links to the current route values (example: in /Products/Details/3 there should not be a link to /Products/Details/3), ignoring other URL params if any. What I can think of is to check if: destination action and controller ...

Controlling Output Indentation in ASP.Net MVC

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...

passing css class name to asp.mvc view helper

In ASP.NET MVC view helper, you can do something like <%= Html.ActionLink("click me", "DoSomething", null, new { someAttribute = "a value" } ) %> which will produce the following HTML <a href="DoSomething" someAttribute="a value">click me</a> My question is.... what if I want to set the "class" attribute? <%= Html.ActionLink("cl...

HtmlHelper Extension - User Conrol

Hi, I have a custom user control called ErrorNotificationBox. To place that on my page I do the old... <%@ Register Src="~/PathTo/ErrorNotificationBox.ascx" TagName="ErrorNotificationBox" TagPrefix="uc" %> <uc:ErrorNotificationBox Runat="server" id="myEnb" Caption="My Test Caption" /> Is it possible to extend HtmlHelper to include ...

Unit Testing HtmlHelper that Needs to Access Data Layer

I am trying to create a unit test for an HtmlHelper that accesses my data layer to get a string. I have looked at a lot of posts around this and I am probably missing something. The problem that I am having is how do I mock the access to my data layer? I usually do my dependency ijection through the constructor, but I cannot here beca...

Html.BeginForm() type of extension.

Does anyone know the syntax for creating a custom HtmlHelperextension method which behaves like.. <% using (Html.BeginForm()) {%> <p>Loads of html stuff here </p> <% } %> I'm thinking of something along the lines of.... <% using (Html.BeginTable("Column Heading 1", "Column Heading 2")) {%> <% } %> Any ideas? Cheers, ETFairfax ...

ASP.Net MVC 2.0 Html.HiddenFor HtmlHelper extension doesn't return the Value.

We're trying to be type-safe in our views and use the new ExpressionInputExtenssion HtmlHelpers, but we are seeing some inconsistent results. We have a view that looks like this: ViewData.Model.FooID = <%= ViewData.Model.FooID %>< Model.FooID = <%= Model.FooID %> <%= Html.HiddenFor(x=>x.FooID) %> But what we see in the rendere...

When should I use HtmlHelper Extension Methods?

I am increasingly finding situations where my ASP.NET MVC view requires some logic to perform layout. These routines have no place being in either my model or my controller. I have 3 options: Write lots of <% %> inline in the view. Write less <% %> in a number of partial views. Write an HtmlHelper Extension method. It is the last opt...

LoadLibrary on OCX file fails in Windows 7 x64

Hi, I need to open a html help file from within a legacy windows application written in old version of C++ Builder. HtmlHelp is loaded via HtmlHelp.ocx, which I am loading via LoadLibrary. This has worked fine for years, but it does not work anymore in Windows 7 x64. It might also fail under Windows7 x86, but I don't have any computer...

Easiest way to open chm files programmatically?

Hi, I have a legacy 32-bit application written in Borland's C++ Builder. I need to show specific pages from within a HtmlHelp file programmatically. Until now I've been doing this via HtmlHelp.ocx, but this does not work on x64 versions of Windows Vista / Windows7 as described in this thread. I can't compile the application as 64-bit e...

CHM Style web-based HELP Utility

I need to create a chm style web-based help. Do you know any such utility? The product is developed on C# and it would be great the help is also developed on C#. Thanks. ...

How can I create a templated control with Asp.Net MVC?

I'm trying to create a templated control with Asp.Net MVC. By templated control, I mean a control that accepts markup as input like so: <% Html.PanelWithHeader() .HeaderTitle("My Header") .Content(() => { %> <!-- ul used for no particular reason --> <ul> <li>A sample</li> <li>A second item...

html helper syntax ?

hello all, please tell me how to give the id to the html textbox my html tag looks like this <%=Html.TextBox("username")%> please help me Thanks Ritz ...