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


ADVERTISEMENT

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

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

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

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

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

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

Getting Syntax Error Converting From Character String

Jan 31, 2011

I have the following code:

Imports System.Data.SqlClient
Public Class Main
Protected WithEvents DataGridView1 As DataGridView

[code]....

When I debug this, I put the line break on that line and look at the Table Value, which shows 0, but I know that there is data for that time frame.

View 14 Replies

Forms :: Syntax Error Converting DateTime From String

Feb 17, 2010

i am using DateTimePicker control....my code is TextBox2.text=DateTimePicker1.Text.......while changing it correctly dispaly the selected date in textbox......the problem is i want to store the date in my database of field datetime type........when i click the add button it shows "Syntax Error Converting DateTime from String"

View 1 Replies

Sql - Syntax Error Converting Datetime From Character String

Sep 2, 2010

Getting this error when updating a row via a gridview with a sqldatasource in Vb.net/SQL Server 2000. No matter what input (1/1/2010, blank, etc) I give it I can't seem to get it right.

Code before the input is passed to the sp:

Dim sqldatenull As DateTime
Dim DateVerify As DateTime
sqldatenull = DateTime.MaxValue

[Code]....

View 1 Replies

Syntax Error Converting Datetime From Character String

Nov 18, 2011

Im in the process of building a call loggin system and its finally been put on the server, but i keep getting the above error "Title" the first stage it goes to be authorised and when the authoriser auths it...it updates the table with the date they authorised it. which is fine, the next stage is the Business Analyst where they check all the content of the task and then approve it but for some reason unknown to me it keeps falling over on the .dateAuthorised

My Sql Column to hold the date authorised is a Datetime datatype and im converting a string to a data time within the procedure this is my Code behind page

Dim StatusNew As Integer = 53
Dim CurrentStage As Integer = 51
ITUpdateTaskTable.Add("@spWorkID", Replace(TskNumLab.Text, "LC", ""))

[Code].....

View 13 Replies

Syntax Error When Converting One Of Applications From C# By Hand(No Program Used)?

Jul 10, 2010

I have made a smtp client in c# and I use this code to split a string that contains multiple recipients.

foreach (var n in txtSendTo.Text.Split(';'))
{
mail.To.Add(n);

[code].....

View 3 Replies

Converting VBA Related To Variant And Array Creation/Initialization Syntax To .Net?

Jun 17, 2011

The following code works fine in VBA Goal of the code is to find (select) all cells in an Excel worksheet where the backgrounf cell color is Yellow (6) or Rose (38)

Sub SelectColorsViaArray()
Dim e As Variant
Dim r As Range
Dim x As Range

[code]....

3) With the above, I still do not understand how to integrate the Variant and Array differences from VB6 to VB.Net. I know what to do with all other like: Application.FindFormat.Interior.ColorIndex ... etc.

View 10 Replies

Sql Server - Getting Syntax Error Converting From Datetime Character String

Jan 28, 2011

I have the following code:

Imports System.Data.SqlClient
Public Class Main
Protected WithEvents DataGridView1 As DataGridView

[Code]....

When I debug this, I put the line break on that line and look at the Table Value, which shows 0, but I know that there is data for that time frame.

View 1 Replies

SqlCeException Unhandled - Syntax Error While Converting From One Data Type To Another

Jul 19, 2011

There was a syntax error while converting from one data type to another. [ Expression = -1 ].

This part of the code where the issue starts is here: Do While JVReader.Read()

Here is the

CODE:

View 2 Replies

Syntax For Blank List View

Mar 15, 2012

what is the syntax for blank list view object... for example:[code]what is the syntax for classlistview is blank? as in no record(s) were retrieved.

View 3 Replies

.net - View T-SQL Syntax Of A Stored Proc-based SqlCommand?

Mar 18, 2010

retrieve the actual T-SQL that is to be executed by a SqlCommand object (with a CommandType of StoredProcedure) before it executes...My scenario involves optionally saving DB operations to a file or MSMQ before the command is actually executed. My assumption is that if you create a SqlCommand like the following:

Using oCommand As New SqlCommand("sp_Foo")
oCommand.CommandType = CommandType.StoredProcedure
oCommand.Parameters.Add(New SqlParameter("@Param1", "value1"))
oCommand.ExecuteNonQuery()
End Using

It winds up executing some T-SQL like:

EXEC sp_Foo @Param1 = 'value1'

Is that assumption correct? If so, is it possible to retrieve that actual T-SQL somehow? My goal here is to get the parsing, validation, etc. benefits of using the SqlCommand class since I'm going to be using it anyway.

View 3 Replies

Visual Studio "Syntax Error." With No Line In An MVC3 Partial View?

Dec 3, 2011

When I open two very small MVC 3 partial view file (*.vbhtml) in Visual Studio 2010 Express SP1, I get a "Syntax Error." with no Line or Column defined. Visual Studio does not tell me what's wrong with these partial view.

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

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







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