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


ADVERTISEMENT

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

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

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

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

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

C# Equivalent Of VB Syntax For Property?

Sep 10, 2009

I found the following syntax as a VB.NET property and I'm trying to convert it to c#, but I'm not sure how to accomplish that.

[code]...

View 5 Replies

VB Equivalent Of C# Syntax - Dealing With Delegates?

Nov 20, 2009

Is it possible to translate the following C# code into VB.NET, using VB 9.0?

delegate Stream StreamOpenerDelegate(String name);

void Exec1()
{
WorkMethod( x => File.OpenRead(x));

[CODE]...

Can I do something like this?:

Private Delegate Function StreamOpenerDelegate(ByVal name As String) As Stream

Private Sub WorkMethod(ByVal d As StreamOpenerDelegate)
''
End Sub

[CODE]...

I'm trying to write some documentation, but I don't know VB syntax. Often I use Reflector to translate it, but I'm not sure it's working in this case. I'm also not clear on where I would need line continuation characters. In VB9, it's not possible to have multi-line lambdas (or Sub lambdas, which I did not ask about). In VB9, all lambdas return a value, and must be a single expression. This changes in VB10. VB10 will allow the above syntax, but VB9 will not. In VB9, if the logic involves multiple code lines, it must not be a lambda; you must put it into a named Function and reference it explicitly.

Like this:

Private Delegate Function StreamOpenerDelegate(ByVal name As String) As Stream

Private Sub WorkMethod(ByVal d As StreamOpenerDelegate)
''
End Sub

[CODE]...

View 1 Replies

What's Equivalent Syntax For Anonymous Types In A LINQ Statement

Jun 29, 2010

I'm trying to translate some C# LINQ code into VB.NET and am stuck on how to declare an anonymous type in VB.NET.[code]How do you translate C#'s new { ... } syntax into VB.NET?

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

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

.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

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

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

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

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

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

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

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

Syntax/Command Trying To Implement Syntax Highlighting In RichTextBox?

Oct 12, 2011

I am having an issue trying to figure this out. I am writing a script editor that uses tabs (a tab control) and I want to implement syntax highlighting. My issue is that every sample I can find on syntax highlighting uses

Private Sub RichTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged

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

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







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