HtmlAttributes On ASP.NET MVC 3 With Razor View?

Apr 7, 2011

how do I add this htmlAttribute on MVC 3 Razor view?

New With {.watermark = "sometext", .title = "sometext"}

I tried the C# way but it's not working (@watermark) but it's not working.

UPDATE here is the current usage I am trying but it's not working.

@Html.EditorFor(Function(model) model.FirstName, New With {.maxlength = "50"})

This isn't working either

@Html.EditorFor(Function(model) model.FirstName, New Object() {"maxlength=50"})

View 3 Replies


ADVERTISEMENT

Access My.Resources From A Razor View?

Jul 6, 2011

I have a razor.vbhtml view and would like to use string resources normally accessible via My.Resources. Seems like I can only get to My.Computer, My.Log and couple other namespaces from the view, but not My.Resources. I've tried changing access modifier to public and adding Imports, neither worked.

View 1 Replies

Asp.net - Html.CheckBoxFor In VB Razor View?

Feb 27, 2011

I have this C# code in a Razor view:

@(Html.CheckBoxFor<RazorSamplesWeb.Models.SamplesModel>(i => i.IsActive))

I tried translating it to this:

@Code Html.CheckBoxFor(Of RazorSamplesWeb.Models.SamplesModel)(Function(i) i.IsActive)End Code

But it's complaining.

View 3 Replies

Asp.net Mvc - Razor View Engine Quirks ?

Nov 12, 2010

I just downloaded the MVC 3.0 RC and I'm excited to start using it, especially the Razor view engine. However, due to a few stick in the mud type people here, we are stuck using VB.NET instead of C#.When I started trying it out, I noticed some quirks. If you are creating a Razor view using CSHTML, you can write code like this:

@foreach(string genreName in Model.Genres)
{
<li>@genreName</li>
}

Razor will automatically detect that the <li> text is an HTML tag and will switch out of "code mode". With a VB.NET VBHTML file, this doesn't seem to be working. It's making me put the @: keyword in front of each line like this:

@For Each genreName As String In Model.Genres
@:<li>@genreName</li>
Next

If I don't have it there, I get a runtime error. Also, the <text></text> tags don't seem to work.

View 3 Replies

Converting C# Razor View Syntax?

Mar 21, 2012

I am new to Razor view syntax and as most of the examples are in C# in coverting the below Razor syntax to vb.net

<div>
@using (Html.BeginForm())
{

[code].....

View 1 Replies

Namespace Reference In .NET MVC3 Razor View In VB?

Jan 25, 2011

How do I reference a Namespace in .NET MVC3 with the Razor view engine?

I understand this can be done in C#:

@using Namespace;

However in VB this doesn't seem to work:

@Imports Namespace

(i'm talking about inside a .vbhtml file)

View 1 Replies

Asp.net Mvc Including File Upload In Razor Form View

Dec 9, 2011

MVC 3, VB.NET. I have a form in my app that gets basic information from the user and then allows them to upload a resume. I am accomplishing this right now by using a redirect to a different form that's only purpose is to select the file for uploading and then submit it.. Sloppy in my opinion.. I have tried to do it from the same form but the file is being lost on submit.. While I am not certain of it I believe it is because I am not using the correct syntax in the form to handle the file.[code]

View 1 Replies

Unable To Use Microsoft.Web.Helpers In Razor View Vbhtml File

Oct 18, 2011

I want to use the Linkshare helper in the Microsoft.Web.Helpers dll. I added the reference to my project but if attempt to use it in the vbhtml file Visual studio underlines it with a blue squiggly and tells me it is inaccessible blah blah. I even added references to those webmatrix dlls as described here[url]...

View 2 Replies

Mvc 3 - MVC3 Razor View Project Gives Syntax Error In Error List Window For All VBhtml Pages?

Feb 22, 2011

Using MVC3 and Razor View engine, I created a VB.NET web application in VS 2010. This creates the default Account and Home Controller along with corresponding Action Views.Now if I open any vbhtml file I get the following error message in the Error List window.

Error 50 Syntax error. C:****MVC3AppVBViewsAccountLogOn.vbhtml MVC3AppVB
(See screenshot here http://www.flickr.com/photos/7672540@N07/5469248676/)

[code].....

View 2 Replies

Asp.net Mvc - Add Dynamic HtmlAttributes To Htmlhelper ActionLinks?

Mar 20, 2010

In my master page I have a top-level menu that is created using ActionLinks:

<ul id="topNav">
<li><%=Html.ActionLink("Home", "Index", "Home")%></li>
<li><%=Html.ActionLink("News", "Index", "News")%></li>

[Code]....

Do I have to overload the ActionLink method to do this, or create an entirely new HtmlHelper, or is there a better way?

View 2 Replies

Asp.net - Converting C# Razor To VB?

Feb 28, 2011

I'm following the ASP.NET MVC Tutorial and having started in VB.NET I'm having trouble converting the following razor code:

[code]...

on both the <li> tags. I understand I need to use line continuation but can't figure out where. I'd be greatful if you can point out the problem.

View 3 Replies

Asp.net Mvc 3 - Translating The Razor Syntax?

Jan 25, 2011

MVC 3 is great but in some cases I am having trouble translating the Razor syntax. Anyone know of a good VB.Net Razor reference?

View 1 Replies

Asp.net Mvc Razor For Loop Syntax

Apr 5, 2012

Trying to create VB.net equivalent for following code and I get error

<ul>
@for (int i=0; i < ViewBag.NumTimes; i++) {
<li>@ViewBag.Message</li>
}
</ul>

View 2 Replies

What Is The .NET Equivalent Of This C# Razor Syntax

Nov 29, 2011

In the MVC 3 book by Steven Sanderson on p185 at the bottom, the following expression is used to render the paging links.

@Html.PageLinks(Model.Paginginfo, x=> Url.Action("List", new {page = x}))

What is the VB.NET equivalent? I am stuck on the x url lambda bit.

View 1 Replies

.net - Concatenate Tag Attribute Value Using Razor And A Prefix

Jun 16, 2011

How do I do this in Razor (VB.NET):

[Code]....

View 1 Replies

Asp.net - @Model Not Supported In Razor Views For VB?

Feb 27, 2011

Is not the @Model MyModelClass notation not supported in VB Razor Views? It's not working for me. What is the construct for it?

View 1 Replies

Mvc - MVC3 Razor SelectedValue In DropdownListFor?

May 30, 2012

I've the following code for a DropDownListFor and is working ok

@Html.DropDownListFor(Function(model) model.Habilitacoes, New SelectList(ViewBag.Habilitacoes, "KeyHL", "DescricaoHL"), New With {.class = "FillHSpace"})

[code].....

View 2 Replies

VB - ASP MVC 3 Razor Extra Whitespace Rendered

Jul 8, 2011

I am getting extra whitespace characters rendered in my horizontal list of anchor tags below. This is causing a major CSS styling issue for me. I know this question has been addressed as far as a C# workaround is concerned (asp.net mvc razor extra space), but can anyone help me with a VB workaround? I don't have the advantage of curly braces to eliminate all whitespace in a single-line If condition.

I have managed to work around it for now by writing an HtmlHelper extension method, but this dynamic code is only used in one place (the master layout page). It seems to me that this should really be done in the .vbhtml page. Here is the erroneous code, along with commented-out attempts at workarounds. The goal is to create a horizontal list of "sibling" pages based on a site map, with slightly different styles for the current page's link and the link just before it. [Code]

View 1 Replies

What's Razor Syntax To Create A Table

Mar 15, 2012

This should not be as hard as it seems to be, but I can't for the life of me create a table in VB using Razor syntax. The following does not work (despite what some examples would lead me to believe):[code]

View 2 Replies

Asp.net - Razor Inline Template Item Keyword In VB?

Feb 27, 2011

Check out this code sample from Scott Guthrie's blog: [URL]...Notice item is a reference to the currently executing item in C#, what is the equivalent keyword in VB.NET?

EDIT: I should add here is my actual implementation of a method accepting a template:

Public Function RenderInlineTemplate(ByVal template As Func(Of RazorSamplesWeb.Models.SamplesModel, Object)) As IHtmlString Return New HtmlString("<div style='display:inline;'>" + template(Model) + "</div>")
End Function And I get this error: Compiler Error Message: BC30201: Expression expected.

[Code]...

View 2 Replies

Asp.net Mvc 3 - .Net, MVC3, And Razor - Modifying ActionLink Helper?

Jun 21, 2011

How do I modify or create my own Html.ActionLink helper to accept and handle the first parameter (linkText) passed in as an empty string / nothing?Details: I currently have a strongly typed view that's passed a model which contains search results. My view loops through each item in the model and attempts to display a link to a contact with the following code:

@Html.ActionLink(currentItem.ContactName, "contact", "details", New With { .id = currentItem.ContactID }, Nothing)

Normally this would work just fine, but not every item in my search result has a ContactName. The Html.ActionLink helper errors when this first parameter is empty. In case it helps, here's the model property for ContactName (which is generated from a template due to Database First, so I don't believe it can be modified):

Public Property ContactName As String

I'd like to have a helper function that simply returns nothing if the ContactName is an empty string / nothing.I'm guessing I need to extend this helper, and I've struggled to find any good, up-to-date resources in VB.net for extending helper functions. Other approaches are more than welcome if they're considered best practice. I'm working in VB.net, MVC3, and Razor in the ASP.net 4.0 framework.

View 2 Replies

Asp.net - Add Razor (cshtml) And C# Projects To A Visual Studio Vb Website?

May 4, 2012

I'm creating a new website in Visual Studio 2010 Ultimate / vb and I want to add things to it, to jazz it up. So I'm adding new projects from the VS online templates. It seems there are many more projects in c# than vb. I'm trying to figure out if it's okay to add a c# and razor project to a vb website, because if not, I'll start the website in c#.

Will mixing languages between projects within your website present issues in the future when it comes time to build and publish? Or is it recommended I begin the website in c# (since there are more projects within VS) and keep the languages the same throughout the website?

View 3 Replies

ASP.Net MVC 3 Razor - Create And Pass Info To A Dynamic Layout?

Jan 10, 2011

In other languages (PHP/Python), I am used to creating a class which represents a given HTML page layout. These classes can have an unlimited number of attributes and dynamic features, such as Navigation (multi level), error messages, info messages, footer text, etc... Most of these items have defaults, but may be overridden on a per-page level. For example:

[Code]....

My question is: how do I implement similar functionality into ASP.Net MVC 3 Razor (VB)? So far, I have been able to see how you can use ViewData to pass various bits of data to a view. Also, I have been working with strongly typed views. Frankly, I'm not sure who's job it is to have this logic, the controller or the view (or is there a model that should be in there somewhere). Here is a summary of what I am shooting for:

A single place to initialize the default values for the layout (like the first layer of navigation, etc...) Strongly typed attributes, such as Public Readonly Property Nav1 as List(of NavElement) And a single place to render these layout elements (I assume _Layout.vbhtml) forgive the here-and-there of this post... I'm trying to figure out the "right way" it's done on a platform that is both new (Razor) and new to me (ASP.Net MVC).

View 3 Replies

Html - Returning A File In A New Browser Window Using Mvc 3 Razor?

Oct 12, 2011

I have a funtion that returns a generated PDF file but the problem is it shows it in the current browser window... I need for it to open in a new window. I dont see how I can pass it into a view for displaying where I could simply use target: _blank.

Function showUserPDF(ByVal pdfName As String) As ActionResult
Dim _fileName As String = pdfName
Dim _path As String = Path.Combine(AppDomain.CurrentDomain.BaseDirectory) +

[Code].....

View 1 Replies

Telerik Grid, Razor And .NET In Ajax Binding Mode?

Dec 19, 2011

I'm trying to create a Grid in MVC3 with razor and VB.NET. The normal Grid works fine, sorts and paginates fine, but when trying to make the Ajax binding, I get an error 500 - internal server error when I try to go to the next page.

[Code]...

View 1 Replies

Increment Local Variable Inside Razor Syntax, MVC3

Sep 21, 2011

I am working on MVC3, i have a situation where i want to do something like this:

<Div>
@Code
Dim i = 1

[Code]....

but razor is throwing wrong syntax error message. how to do this properly in side razor code.

View 1 Replies

Make Code Indentation Behave Correctly In Vbhtml Razor Files?

Nov 25, 2011

This is driving me round the bend. I'm a long time VB.NET forms developer, quite new to ASP.NET and completely new to MVC. I'm creating vbhtml pages that use the VB.NET razor syntax, and I seem to be constantly fighting against the UI which is trying to indent my code incorrectly. Take the following example, based on the template page for a new Razor view:

@Code
Layout = Nothing
End Code

[code].....

View 2 Replies

Fill In Data Grid View With Columns And Rows To Form Complete View

Nov 11, 2010

i have datagridview populated with stock code, name and description.And i have docked my datagridview to the bottom. so whenever the form is resized, the bottom section will be occupied completely with the datagridview.But i want to display one extra empty column and multiple empty rows to completely fill in the datagridview.The extra empty column width will be adjusted to the right end side of datagridview.And the no of empty rows will be generated based on how many is required to fill up to the bottomSo that i can create datagridview with full column and row even though some columns or rows are empty.

View 1 Replies

Convert A Html String Or The Below Sting Into A Tree View Or A List View

Jun 9, 2009

the VB .net experts. I added the following code and I get an error as shown below.

[CODE]....

View 8 Replies

Develop A Tree View And List View Form By Using Vb6?

Dec 29, 2009

I want to develop a tree view and list view form by using vb6, how to construct a tree view and list view form?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved