In Html 5, there is an new attribute on textbox call autofocus.
The problem is it is a boolean value (there or not there)
It should look something like :
<input name="a" value="" autofocus>
I try :
<%= Html.TextBox( "a", null, new { autofocus } ) %>
But, it's give me an error because I'm not setting a value to autofocus...
I kno...
I have a class MyController that inherits from Controller, so all my controllers inherit from MyController.
I have a property in MyController:
public class MyController : Controller
{
public string SomeProperty {get;set;}
}
if I set this property in MyController's OnExecuting method, my HtmlHelper extension method works fine:
pu...
In my controller I create a list of SelectListItems and store this in the ViewData. When I read the ViewData in my View it gives me an error about incorrect types. If I manually cast the types it works but seems like this should happen automatically. Can someone explain?
Controller:
enum TitleEnum { Mr, Ms, Mrs, Dr };
var titles = n...
Hi,
I want to create a pagination helper. The only parameters that it needs are currentpage, pagecount and routename.
However, I do not know if it is possible to use the return value of another html helper inside the definition of my html helper. I am referring specifically to Html.RouteLink. How can I go about doing something like this ...
Simple question, if you use the Html Helper from ASP.NET MVC Framework 1 it is easy to set a default value on a textbox because there is an overload Html.TextBox(string name, object value). When I tried using the Html.TextBoxFor method, my first guess was to try the following which did not work:
<%: Html.TextBoxFor(x => x.Age, new { va...
Trying to add a 'class' html attribute, but I think the keyword 'class' is causing issues.
<%: Html.TextBox("name", "value", new {class: " required "})%>
Is there a workaround?
...
Just wondering what the difference is between these two and what the benefit for one or the other of them would be when I build my table in my HtmlHelper
HtmlTable table = new HtmlTable();
and:
TagBuilder table = new TagBuilder("table");
This is more or less the same as this question,
http://stackoverflow.com/questions/3043654/wh...
Why does my html helper extension work if I do:
<%= Html.MyExt() %>
all mvc helpers work like:
<% Html.TextBox(""); %>
My extension builds a StringBuilder, then returns a string.
...
Hi there, quick question...
How can I best create internal links? This is the markup I want to achieve:
<h3>Title</h3>
<ul>
<li><a href="#prod1">Product 1</li>
<li><a href="#prod2">Product 2</li>
<li><a href="#prod3">Product 3</li>
...
<li><a href="#prod100">Product 100</li>
</ul>
<div id="prod1">
<!-- content here -->
</d...
I have written a class which implements IModelBinder (see below). This class handles a form which has 3 inputs each representing parts of a date value (day, month, year). I have also written a corresponding HtmlHelper extension method to print out three fields on the form.
When the day, month, year inputs are given values which can be p...
OK, let's start with the Html.Textbox. It is supposed to contain text read from a file. The file read is based on what the user picks from a dropdown list.
The first time it is fine. The user picks a value from the dropdown list. The controller uses that value to read some text from a file, and returns that text to the view via the view...
We are in the process of upgrading an ASP.NET MVC 1.0 application to the 2.0 release and some of the code requires the use of LinkExtensions which require an HtmlHelper to render. While we know that some of the code doesn't follow the MVC model correctly and are in the process of recoding as needed, we need something to work so get the a...
Hello,
I have simplified my work for this question but the same problem remains. I am using the Textbox HTML helper to display empty textboxes as I loop through the items in this model.
<% foreach (var item in Model) { %>
<tr>
<td><%: item.ID %></td>
<td><%: Html.TextBox("usernames", null, new { @class = "datepicker" }) %></td>
<td><...
I've been trying to figure out why this isn't valid (according to VS2008).
//Global variable
var sortFields;
$(document).ready(function() {
sortFields = <%= CustomHtmlHelper.ToJson(ViewData["SortInfo"])%>;
//Other Code here...
});
My HtmlHelper code
public static string ToJson(object obj)
{
var serializer = n...
Ok so I want to know how
<% using (Html.BeginForm()) { %>
<input type="text" name="id"/>
<% } %>
produce
<form>
<input type="text" name="id"/>
</form>
namely how does it add the </form> at the end? I looked in codeplex and didn't find it in the htmlhelper. There is a EndForm method, but how does the above know to call it?
The...
Hi,
I am trying to update the Roles a specific group has in my application. The Group model I use in my view has an additional AllRoles IEnumerable attached to it, so that in my view I can do something like this:
<%: Html.ListBoxFor( model => model.aspnet_Roles, new MultiSelectList( Model.AllRoles, "RoleId", "RoleName" ), new { @class =...
I have a radio button list like this
<%=Html.RadioButtonFor(m => m.Gender,"Male")%> I should make this button selected by default.
Any inputs ??
...
We have a small Asp.Net MVC project which displays a report of several tens or hundreds of rows of data. Each row is represented by an object on the view models.
Currently we are showing the rows like this:
<table>
<tr style="text-align:center">
<th>Name</th>
<th>Item count</th>
<th>Stat 1</th>
<th>St...
In my controller I generated a SelectList that I pass to the dropdown helper:
<%= Html.DropDownList("abc123", Model.SomeList) %>
I look at the querystring for a value, which is a ID.
I then loop through all the items in the SelectList and if it is equal to the ID, I do:
item.Selected = true;
The controller action then passes thi...
I saw this implemented somewhere but basically below I'm using the textbox HTMLHelper to draw a textbox with the id myID and default text 'text_goes_here'. I want to also add a class to thiis helper, i saw somewhere it implemented with new {@class =''} as a third parameter creating an object but im not sure exactly how its wrote
<%= Ht...