Why Can't Use C# Syntax In Inherits Attribute For A Closed Generic But CLR Syntax Is Fine

Jan 15, 2011

The following CLR syntax works fine in my aspx page:

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="Website.MyBasePage`1[HomePageViewModel]" %>

But this C# syntax does not:

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="Website.MyBasePage<HomePageViewModel>" %>

Note, I am not using ASP.NET MVC, but this works fine if using System.Web.Mvc.ViewPage<> from ASP.NET MVC.
My MyBasePage looks like this:

public class MyBasePage<TModel> : Page where TModel : class {
public TModel Model
{
get { return (TModel)HttpContext.Current.Items["model"]; }
}
}

View 1 Replies


Similar Messages:

Mvc Views With CLR Generics Syntax In Inherits Attribute?

Oct 18, 2010

For reasons I won't go into I need to use CLR generics syntax in an ASP.NET MVC view.

I.E. NOT this:

System.Web.Mvc.ViewUserControl<someobject>

but this:

System.Web.Mvc.ViewUserControl`1[[someobject]]

When I run the application I get

Parser Error: could not load type `System.Web.Mvc.ViewUserControl`1[[someobject]]

View 2 Replies

Syntax Error During Generic List Initialization?

Apr 27, 2010

I am creating a generic list of objects using this syntax:

[Code]....

View 1 Replies

Access :: Syntax Error (missing Operator) In Query Expression / Get Conflict With CommandText Syntax

Aug 8, 2010

I'm having problem in inserting text from a textbox in which user write or copy some text which may contain special characters ( " , . ) etc. If there is any special character it get conflict with CommandText Syntax and generates error in inserting. I want to insert all these characters. How could i do it?

Code:

[code]....

View 1 Replies

MVC :: 3 RC2 - Convert ASPX Syntax To Razor Syntax For Asp:Hyperlink?

Dec 15, 2010

For reporting we used report RDLCs and displayed using an ASPX form. We implemented using the route as shown below. This resulted in forcing us to use the page route below and also to use the hyperlink instead of the normal Action Link. The question is how do we convert the asp:hyperlink ASPX syntax to Razor syntax.

//Custom route for reports routes.MapPageRoute( "ReportRoute", // Route name "Reports/{reportname}", // URL "~/Reports/{reportname}.aspx" // File );
<li><asp:HyperLink ID="hypReport" runat="server" NavigateUrl="<%&#36;RouteUrl:routename=ReportRoute,reportname=StaffRpt%>">Staff Report</asp:HyperLink></li>

View 2 Replies

SQL Server :: EXEC 17P_Comose Will Give Incorrect Syntax Error - Incorrect Syntax Near '17'

Sep 15, 2010

I am working with a sql server database with about 50 stored procedures. The database and stored procedureswere not created by me. The stored procedures all begin with a number in their name.

Example: 17P_Comsetter

The problem I am having is that if I try and execute the stored procedure at the command line in Query Analyzer,the query analyzer appears not to like that the stored procedure begins with a number. For example:

If I try an run the stored procedure as follows:

EXEC 17P_Comsetter

Then I get the following error message:

Msg 102, ..... Incorrect Syntax near '17'

I am using SQL server 2005. Does anyone know why I am getting this error message?

View 1 Replies

ADO.NET :: Not Working Showing Syntax Error Syntax Error:operand Is Missing?

Mar 25, 2011

DataRow[] filterRows = ds.Tables[0].Select("Running Status= case State when 'True' then 'Running' When 'False' Then 'Stoped' end Where Active='1' and State='1'");

this is not working showing syntax error syntax error:operand is missing

View 3 Replies

DataSource Controls :: Declare Attribute With Select Top 1 / Error Incorrect Syntax Near The Keyword 'select'

Apr 14, 2010

I will declarate a attribute, but it gives me an error

This query works fine and returns 1 record from type int:

SELECT TOP 1 DataObjectVersionID
FROM tblDataObjectVersionPropertyValueText
WHERE PropValue like CAST('00010281' AS ntext)
ORDER BY DataObjectVersionID DESC

And when I will declarate a attribute/parameter it gives me an error:

DECLARE @dataObjectVersionId INT
SET @dataObjectVersionId = SELECT TOP 1 DataObjectVersionID
FROM tblDataObjectVersionPropertyValueText
WHERE PropValue like CAST('00010281' AS ntext)
ORDER BY DataObjectVersionID DESC

Error message:

Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'SELECT'.

View 4 Replies

Set The Inherits Attribute Of An ASPX Page Directive To A Class In An Arbitrary Assembly?

Feb 24, 2011

Is it possible to set the Inherits attribute of an ASPX Page directive to a class in an arbitrary assembly?

I need to modify an ASP.NET (1.1) application for which the source code was lost. In a new assembly (foo2.dll) I've created a replacement code-behind class that derives from the original class in the site's code-behind assembly (foo.dll). It seems easy enough to set the Inherits attribute of the Page directive to the new class name, but when I do that the web server gives me Could not load type 'Foo2.checkout2'. I am referencing the new assembly in the <assemblies> section of Web.config.

I don't see anything in the documentation to indicate that this scenario is unsupported, but I'm not certain that it is, either.

Original

<%@ Page Inherits="Foo.checkout" language="c#" Codebehind="checkout.aspx.cs" AutoEventWireup="false" %>

New

<%@ Page Inherits="Foo2.checkout2" CodeFile="checkout2.aspx.cs" CodeFileBaseClass="Foo.checkout" language="c#" Codebehind="checkout.aspx.cs" AutoEventWireup="false" %>

View 1 Replies

Error About "Inherits" Attribute Even Though It's Correct?

Sep 23, 2010

Having a really strange issue at the moment with an ASP.NET site I'm currently building. At the moment, I'm writting the HTML and CSS for a page called Dashboard.aspx. But when I go to view the page in a browser, half the time it throws up this error: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl). I've checked the Inherits attribute on the .aspx page, and it matches the Partial Class held in the VB code of Dashboard.aspx.vb file.

When I refresh, it will always come up with this error. Then after a minute or two, it will load fine with no problems. I had a quick look on Google and I couldn't find an answer to this issue. I have also changed the name of the partial class (and the content placeholder on the .aspx file, thinking that may have caused a conflict) and nothing I do seems to fix it. Could anyone shed any light on what's going on?

View 1 Replies

Syntax Near The Keyword?

Jul 4, 2010

I am trying to use this code:
PHP Code:

string connVac = "Database connection...";
SqlConnection dbConnVac = new SqlConnection(connVac);

DataSet dsInfo = new DataSet();

[code]....

But i need to change it so it shows the Job name, details and then the regions..

View 5 Replies

C# - Sql Syntax How To Do A Join

Mar 24, 2011

Im trying to retrieve a path name from my Pictures table the pathname is stored under picturepath in my Pictures table I dont know how to join it on to my current sql syntax it uses the UserID which is set by a session.

And im unsure what goes in the commented line for my image url string?

using (OdbcCommand cmd = new OdbcCommand("SELECT Wallpostings FROM WallPosting WHERE UserID=" + userId + " ORDER BY idWallPosting DESC", cn))
{
using (OdbcDataReader reader = cmd.ExecuteReader())
{
test1.Controls.Clear();
while (reader.Read())
{
System.Web.UI.HtmlControls.HtmlGenericControl div = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
div.Attributes["class"] = "test";
//div.Style["float"] = "left";
div.ID = "test";
Image img = new Image();
img.ImageUrl = String.Format("{unsure}", reader.GetString(unsure));
// this line needs to be represented in sql syntax
img.AlternateText = "Test image";
div.Controls.Add(img);
div.Controls.Add(ParseControl(String.Format("{0}", reader.GetString(0))));
div.Style["clear"] = "both";
test1.Controls.Add(div);

View 1 Replies

Understanding Syntax In C#?

Apr 23, 2010

understand what is going on in the code line below:

Table t = (Table)Page.FindControl("Panel1").FindControl("tbl");
I understand Page.FindControl("Panel1").FindControl("tbl");
Why is there a (Table) before the Page.FindControl?

View 4 Replies

C#, Vb.net Syntax Highlighter?

Apr 10, 2010

I am looking for a code to HTML converter.Let say I have a code

[Code]....

which is in formatted color. Now when I am converting it to the basic HTML convertor it is giving me without color.I have found http://www.manoli.net/csharpformat/ which is generating CSS for the same, which is not possible to add at runtime.

View 12 Replies

ADO.NET :: Incorrect Syntax Near ')'.

Dec 2, 2010

Server Error in '/' Application.

Incorrect syntax near ')'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near ')'.

Source Error:

[Code]....

Line 25:SqlDataAdapter sda = new SqlDataAdapter(cmd);Line 26:DataSet ds = new DataSet();Line 27:sda.Fill(ds);Line 28:Label1.Text = ds.Tables.Count.ToString();Line 29:

View 3 Replies

Converting VB To C# - What Is Proper Syntax

Jul 6, 2010

I am trying to conver this to C# but Item is not a method in C#

Repno is a string variable of 3 characters

First if rep is not null

then

confirm that Repno the field salespnno from the query.

[code]....

View 2 Replies

C# - Parseable MVC Razor Syntax

Sep 15, 2010

Here is what I would like to express by Razor:

<b>@parameterMapping.Title</b> (Category: @parameterMapping.Category.Title, Regexp: @parameterMapping.Regexp)

But to make it parseable I have to write it this way:

<b>@parameterMapping.Title</b> <text>(Category: </text> @parameterMapping.Category.Title <text>, Regexp:</text> @parameterMapping.Regexp <text>)</text>

Are there better ways to solve this problem?

View 1 Replies

Use Razor Syntax In Web Application (not MVC)?

Feb 27, 2011

How does one create a .cshtml page in an ASP.NET web application? The option to choose Razor is obvious when using MVC - it appears when adding a view. But I can't seem to figure out how to accomplish this in a plain ASP.NET Web Application. Is it even possible?

View 1 Replies

Syntax For Retrieving A Value From A SqlDataSource?

Dec 28, 2010

the syntax for retrieving a value from a SqlDataSource? I've managed to get it working using numbers to represent the column, but I'd much rather use it's DB name?

[Code]....

View 2 Replies

MVC :: 2 - Syntax For External Link

Oct 22, 2010

I am trying to create a link that is distributed via eMail. This link will direct the user to a View inside my MVC2 application. I will need to pass 2 parameters with this link. Background: The eMail is an invitation. The user will click the link inside the eMail to RSVP for a meeting. When the link is clicked I want the user to be directed to a certain controller action/view. The parameters will be an eMail address (string) and a meeting ID (int).

The controller action will use the parameters to process logic that determines what the view will display.
An example using the following would be perfect:

Controller action / View name: RSVPmeeting
Parameter: AttendeeEMail (string)
Parameter: MeetingID (int)

View 3 Replies

C# - What Is The Syntax For If False In NVelocity

Feb 9, 2010

What is the syntax for an not true or false if statement in nVelocity (or Velocity)?

And more importantly, where is this in the nVelocity docs? I've been Googling for quite a while to no avail.

I've tried several different combinations such as:
#if (!$artist.IsFestival)
$artist.FestivalName
#end
and
#if ($artist.IsFestival == false)
$artist.FestivalName
#end

So frustrating!

View 1 Replies

ADO.NET :: Default Values In SQL Syntax / MVC?

Aug 24, 2010

I have a repository function called getList which retrieves certain information that gets posted to it from a form. My form has 6 fields, and a user can enter searvh criteria in any or all the fields. According to what he has entered, I must execute a SQL string to retrieve matching information.

I have the following:

[Code]....

But, if a user enters only a surname, my query will return no results. Is there a way format my sql string to allow default values, or maybe build the sql string at runtime. In MS-SQL it was easy to do, but how would one do it in LINQ??

View 6 Replies

Asp - Syntax Error In FROM Clause

Oct 18, 2010

I'm working on asp.net web application & for this use MS access for back end, My Query is given below which is successfully executed on MS Access but error on front end ("Syntax Error in FROM Clause")

select USER.EMPID as EMPID,USER.FULLNAME as FULLNAME,
USER.USERNAME as USERNAME,Employee.ROLEID,ROLE.ROLENAME AS ROLE
FROM USER
inner join employee on user.userid=employee.userid
inner join role on employee.roleid=role.roleid
WHERE USER.EMAIL='admin@itiersolutions.com'
AND USER.PASSWORD='cZdqAEeDV2EVzA1JNFJ6hQ=='
AND USER.STATUS='Enable'

View 4 Replies

SQL Server :: Correct Syntax To Do A LIKE In VB.net?

Oct 12, 2010

I want to do a LIKE clause in an SQL statement. What is the proper syntax if this if my informaiton.I want to select personID, personName, personBuilding From Table: main27WHERE personName has the Name 'Smith' in it. Note that person Name is set up as: Last Name, First Name = Smith, John.The query works fine in my access database, but I am trying to put it in a VB.net application and I can't get it to pull any records when there are 18.

View 6 Replies

ADO.NET :: Getting Error / Incorrect Syntax Near ''

Nov 14, 2010

I keep getting the error: 'Incorrect Syntex near 'treatmentMedication'. Syntex error:

[Code]....

This is my class code:

[Code]....

View 2 Replies







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