.NET Framework - Extensions for MVC2 strongly typed HTML helpers

Asked By Dylan Parry
18-Mar-10 08:47 AM
Hi,

I?d like to write some HTML helper extensions so that I can use some of
the HTML5 form fields within MVC2. Basically, where I?ve now got:

Model.Date))%>

I?d like to be able to use something like:

Model.Date))%>

and have it create HTML that looks like:


Likewise, I?d like HTML helpers for url, email, number, and all the
other HTML5 form fields.

I?m just not sure where to start. Ideally someone else would have
already written extensions for these elements, but I can?t find any
anywhere.

Does anyone have a link to a tutorial that explains how to create
strongly-typed HTML helpers? Or failing that, is anyone here able to
point me in the right direction with a bit of starter code?

Cheers,

--
Dylan Parry
String.Format
(1)
Format
(1)
Opera
(1)
News.eternal
(1)
Helpers
(1)
Hnt7dd
(1)
Hntcl5
(1)
Doesn
(1)
  Patrice replied to Dylan Parry
18-Mar-10 09:47 AM
The code is available as a download so in the worst case you could check how
this is done (http://aspnet.codeplex.com/releases/view/41742).

As a side note which HTML 5 browser do you use ? Does it really have support
for validating type="date" fields ?

--
Patrice

discussion : hnt7dd$6kt$1@news.eternal-september.org...
  Dylan Parry replied to Patrice
18-Mar-10 10:17 AM
That?s a good point. Thanks!


I personally use Chrome, which doesn?t currently support all of the
different form fields, but they are being added slowly. I believe that
Opera has full (or close to full) support for the form fields though.

I?m actually building a totally closed CMS for me to manage a site of
mine. As the only user will be me, and I?ll always be using a modern
browser, I can certainly afford to tinker with HTML5 on this project. I
probably wouldn?t use it in the wild though, not unless I could ensure
graceful degradation.

--
Dylan Parry
  Patrice replied to Dylan Parry
18-Mar-10 10:58 AM
Thanks, not targetting this but being curious I just wanted to see some of
those new input type fields in action...

--
Patrice

discussion : hntcl5$4h1$1@news.eternal-september.org...
Create New Account
help
As Object, ByVal e As System.EventArgs) Handles Me.Load Me.BodyTag.Attributes.Add("onclick", String.Format("if(event.type = = 'click'&&event.srcElement.id = = 'div1'){{window.open('downloadfile.aspx?filepath = {0}&extension 1}', 'newwindow');}}", Server.UrlEncode("C: | config.sys"), Server.UrlEncode(".sys"))) Me.BodyTag.Attributes.Add("onmouseover", String.Format("if(event.type = = 'mouseover'&&event.srcElement.id = = 'div2'){{window.open('downloadfile.aspx?filepath = {0}&extension give. ASP.NET Discussions Windows Vista (1) EventArgs (1) UrlEncode (1) Dialog (1) Download (1) Format (1) Load (1) JavaScript (1) i'd guess its a bug with the IE builtin that it works in other browsers too, and it works just fine in Firefox 2, Opera 9 and Netscape 8 (after disabling some popup blocking in each). - - Göran Andersson _ __ __ http
Open() Dim com As OleDbCommand = conn.CreateCommand() Using (com) com.CommandType = CommandType.Text com.CommandText = String.Format("Insert Into help(Name, Email, telephone, description) Values ('{0}', '{1}', '{2}', '{3}')", txtName.Text, txtEmail and adds it to a MS Access Database. It then shows a message that the opera
server by postback, form submit) and draws a blank page. There is no problem with Opera 9.2 and Firefox 2.0. I have tried the following suggestions to resolve the void RedirViaMeta(string theURL) { Response.ClearHeaders(); Response.Clear(); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Write(string.Format(@"<meta http-equiv = ""refresh"" content = ""0;url = {0}"" / > ", theURL)); Response.End(); } public int ClientCnt; protected
ersetzt gegen: For r = 1 To 1000 Add_Renamed("<tr> ") For c = 1 To 10 Add_Renamed(String.Format("<td> {0}-{1}< / td> ", r, c)) Next Add_Renamed("< / tr> ") Next - - Viele Grüsse Peter Da sich nachfragen, warum er den Download von exe'n blockiert. Warum das? Das geht auch mit Opera, firefox und altem IE. Das ist auch bei VB6 erforderlich, indem das Setup entsprechend angepasst