hi im getting the above warnings in VS2010 on my code behind page and its preventing tellisense from working on the page, ive googled but nothing has come up
can anyone explain what could cause this and how to stop it
my code for the aspx and c# pages are below
Thanks
############# CODEBEHIND ####################
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Reflection;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Windows.Forms;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//CompanyData.Accessor.InsertOrUpdateTemplate(1, "Template 1", "Alex", "Companies", "Fred", "test");
// Create the custom button using the Editor.CreateCommandButton method
// Themes/%ThemeName%/Images/text.gif
WebControl ctrl = Editor1.CreateCommandButton("MyButton", "text.gif", "Insert My Custom Text");
ctrl.Attributes["onclick"] = "CuteEditor_GetEditor(this).ExecCommand('PasteHTML',false,'<h2>Hello World</h2>')";
//get the pos after the Italic
int pos = Editor1.ToolControls.IndexOf("Italic") + 1;
//add this custom button into the editor
Editor1.InsertToolControl(pos, "MyButton", ctrl);
Editor1.EditorBodyStyle = "font-family: Century Gothic;";
//Editor1.FrameStyle.Width = Unit.Percentage(100);
Dictionary<string, string> list = new Dictionary<string, string>();
list.Add("", "Please Select a Category");
FieldsList.DataSource = list;
FieldsList.DataTextField = "Value";
FieldsList.DataValueField = "Key";
FieldsList.DataBind();
FieldsList.Attributes.Add("ondblclick", "javascript:setContent();");
}
protected void SaveTemplate(object sender, EventArgs e)
{
//MessageBox.Show("Calling SaveTemplate method!");
var TemplateContent = Editor1.Text;
TestBox.Text = TemplateContent;
//
//WHEN I REMOVE THE BELOW TRY THE CONTENT COPIES TO TestBox FINE
//
try
{
//int StrID, string StrName, string StrCreator,
//string StrCategory, string StrEditedBy, string StrContent
CompanyData.Accessor.InsertOrUpdateTemplate(1, "Template 1", "Alex", "Companies", "Fred", TemplateContent);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error");
}
}
protected void CompaniesList(object sender, EventArgs e)
{
Dictionary<string, string> CompFields = new Dictionary<string, string>();
var CompColName = "";
string CompExclude = ",ID,ACK,RMID,DateAdded,Sec1,Sec2,Sec3,Sec4,Sec5,CompanyType,Constructionline,CHAS,Notes,Locked,CompanyID,Password,Private,";
var CompModel = new AttributeMappingSource().GetModel(typeof(AthenaDataDataContext));
foreach (var CompMT in CompModel.GetTables())
{
if (CompMT.TableName == "dbo.CompanyInfo" || CompMT.TableName == "dbo.CompanyContacts")
{
foreach (var CompDM in CompMT.RowType.DataMembers)
{
CompColName = CompDM.MappedName;
string CompKey = "|" + CompColName + "| ";
if (!CompFields.ContainsKey(CompKey))
{
var CompTemp = "," + CompColName + ",";
if (!CompExclude.Contains(CompTemp))
{
CompFields.Add(CompKey, CompColName);
}
}
}
}
}
var CompSort = (from entry in CompFields orderby entry.Value ascending select entry);
FieldsList.DataSource = CompSort;
FieldsList.DataTextField = "Value";
FieldsList.DataValueField = "Key";
FieldsList.DataBind();
UpdatePanel1.Update();
}
protected void ApprenticeList(object sender, EventArgs e)
{
Dictionary<string, string> AppFields = new Dictionary<string, string>();
var AppColName = "";
string AppExclude = ",ID,ack,rm_id,date_added,sec1,sec2,sec3,sec4,sec5,Appany_type,constructiononline,chas,notes,locked,Appany_id,password,private,";
var AppModel = new AttributeMappingSource().GetModel(typeof(AthenaDataDataContext));
foreach (var AppMT in AppModel.GetTables())
{
if (AppMT.TableName == "dbo.Apprentices")
{
foreach (var AppDM in AppMT.RowType.DataMembers)
{
AppColName = AppDM.MappedName;
string AppKey = "|" + AppColName + "| ";
if (!AppFields.ContainsKey(AppKey))
{
var AppTemp = "," + AppColName + ",";
if (!AppExclude.Contains(AppTemp))
{
AppFields.Add(AppKey, AppColName);
}
}
}
}
}
var AppSort = (from entry in AppFields orderby entry.Value ascending select entry);
FieldsList.DataSource = AppSort;
FieldsList.DataTextField = "Value";
FieldsList.DataValueField = "Key";
FieldsList.DataBind();
UpdatePanel1.Update();
}
}
AWilderbeast
Member
75 Points
118 Posts
statement cannot appear outside of a method body /multiline lambda warnings prohibiting tellisens...
Jan 27, 2011 09:06 AM|LINK
hi im getting the above warnings in VS2010 on my code behind page and its preventing tellisense from working on the page, ive googled but nothing has come up
can anyone explain what could cause this and how to stop it
my code for the aspx and c# pages are below
Thanks
############# CODEBEHIND #################### using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Reflection; using System.Data.Linq; using System.Data.Linq.Mapping; using System.Linq; using System.Windows.Forms; public partial class Default2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //CompanyData.Accessor.InsertOrUpdateTemplate(1, "Template 1", "Alex", "Companies", "Fred", "test"); // Create the custom button using the Editor.CreateCommandButton method // Themes/%ThemeName%/Images/text.gif WebControl ctrl = Editor1.CreateCommandButton("MyButton", "text.gif", "Insert My Custom Text"); ctrl.Attributes["onclick"] = "CuteEditor_GetEditor(this).ExecCommand('PasteHTML',false,'<h2>Hello World</h2>')"; //get the pos after the Italic int pos = Editor1.ToolControls.IndexOf("Italic") + 1; //add this custom button into the editor Editor1.InsertToolControl(pos, "MyButton", ctrl); Editor1.EditorBodyStyle = "font-family: Century Gothic;"; //Editor1.FrameStyle.Width = Unit.Percentage(100); Dictionary<string, string> list = new Dictionary<string, string>(); list.Add("", "Please Select a Category"); FieldsList.DataSource = list; FieldsList.DataTextField = "Value"; FieldsList.DataValueField = "Key"; FieldsList.DataBind(); FieldsList.Attributes.Add("ondblclick", "javascript:setContent();"); } protected void SaveTemplate(object sender, EventArgs e) { //MessageBox.Show("Calling SaveTemplate method!"); var TemplateContent = Editor1.Text; TestBox.Text = TemplateContent; // //WHEN I REMOVE THE BELOW TRY THE CONTENT COPIES TO TestBox FINE // try { //int StrID, string StrName, string StrCreator, //string StrCategory, string StrEditedBy, string StrContent CompanyData.Accessor.InsertOrUpdateTemplate(1, "Template 1", "Alex", "Companies", "Fred", TemplateContent); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } } protected void CompaniesList(object sender, EventArgs e) { Dictionary<string, string> CompFields = new Dictionary<string, string>(); var CompColName = ""; string CompExclude = ",ID,ACK,RMID,DateAdded,Sec1,Sec2,Sec3,Sec4,Sec5,CompanyType,Constructionline,CHAS,Notes,Locked,CompanyID,Password,Private,"; var CompModel = new AttributeMappingSource().GetModel(typeof(AthenaDataDataContext)); foreach (var CompMT in CompModel.GetTables()) { if (CompMT.TableName == "dbo.CompanyInfo" || CompMT.TableName == "dbo.CompanyContacts") { foreach (var CompDM in CompMT.RowType.DataMembers) { CompColName = CompDM.MappedName; string CompKey = "|" + CompColName + "| "; if (!CompFields.ContainsKey(CompKey)) { var CompTemp = "," + CompColName + ","; if (!CompExclude.Contains(CompTemp)) { CompFields.Add(CompKey, CompColName); } } } } } var CompSort = (from entry in CompFields orderby entry.Value ascending select entry); FieldsList.DataSource = CompSort; FieldsList.DataTextField = "Value"; FieldsList.DataValueField = "Key"; FieldsList.DataBind(); UpdatePanel1.Update(); } protected void ApprenticeList(object sender, EventArgs e) { Dictionary<string, string> AppFields = new Dictionary<string, string>(); var AppColName = ""; string AppExclude = ",ID,ack,rm_id,date_added,sec1,sec2,sec3,sec4,sec5,Appany_type,constructiononline,chas,notes,locked,Appany_id,password,private,"; var AppModel = new AttributeMappingSource().GetModel(typeof(AthenaDataDataContext)); foreach (var AppMT in AppModel.GetTables()) { if (AppMT.TableName == "dbo.Apprentices") { foreach (var AppDM in AppMT.RowType.DataMembers) { AppColName = AppDM.MappedName; string AppKey = "|" + AppColName + "| "; if (!AppFields.ContainsKey(AppKey)) { var AppTemp = "," + AppColName + ","; if (!AppExclude.Contains(AppTemp)) { AppFields.Add(AppKey, AppColName); } } } } } var AppSort = (from entry in AppFields orderby entry.Value ascending select entry); FieldsList.DataSource = AppSort; FieldsList.DataTextField = "Value"; FieldsList.DataValueField = "Key"; FieldsList.DataBind(); UpdatePanel1.Update(); } }##################### ASPX PAGE ################# <%@ Page MasterPageFile="~/master.master" AutoEventWireup="true" Theme="Default" Title="CHANGED TITLE" CodeFile="Default2.aspx.cs" Inherits="Default2" %> <asp:Content ID="Menu" runat="server" contentplaceholderid="LeftFloat"> <div id="LeftFloat"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <h2>1. Select Category</h2> <ul> <li><a href="javascript:;" id="CompaniesLink" runat="server" onserverclick="CompaniesList">Companies</a></li> <li><a href="javascript:;" id="ApprenticeLink" runat="server" onserverclick="ApprenticeList">Apprentices</a></li> <li>Other 1</li> <li>Other 2</li> </ul> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <h2>2. Select Field(s)</h2> <asp:ListBox ID="FieldsList" runat="server" rows="20" width="175px"> </asp:ListBox> <h2>Saved Templates</h2> <ul> <li><a href="javascript:SaveTemplate();" id="SaveTemplateLink" runat="server">Save current page as template...</a></li> <%--!<li><a href="javascript:;" id="SaveTemplateLink" runat="server" onserverclick="SQLSaveTemplate">Save current page as template...</a></li>--%> <li>Template 1</li> <li>Template 2</li> <li>template 3</li> </ul> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="CompaniesLink" /> <asp:AsyncPostBackTrigger ControlID="ApprenticeLink" /> </Triggers> </asp:UpdatePanel> </div> </asp:Content> <asp:Content ID="Content" runat="server" contentplaceholderid="RightFloat"> <div id="RightFloat"> <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"> <ContentTemplate> <script language=javascript> function setContent() { // get the cute editor instance var editor1 = document.getElementById('<%=Editor1.ClientID%>'); var ListValue = document.getElementById('<%=FieldsList.ClientID%>').value; editor1.setHTML(editor1.getHTML() + ListValue); } function SaveTemplate() { var button = document.getElementById('<%=SaveTemplateButton.ClientID%>'); button.click(); } </script> <CE:Editor ConfigurationPath="~/CuteSoft_Client/CuteEditor/Configuration/MyTools.config" runat="server" id="Editor1" Height="500" width="100%" ThemeType="Office2003"></CE:Editor> <input type="button" id="SaveTemplateButton" runat="server" style="visibility:hidden" onserverclick="SaveTemplate" /> <p><asp:Label ID=Output runat="server" text=testing></asp:Label></p> <asp:TextBox id="TestBox" name="TestBox" TextMode="MultiLine" Width="500" Height="150" runat="server"></asp:TextBox> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="SaveTemplateButton" /> </Triggers> </asp:UpdatePanel> </div> </asp:Content>Yasser Shaik...
Participant
872 Points
251 Posts
Re: statement cannot appear outside of a method body /multiline lambda warnings prohibiting telli...
Jan 27, 2011 11:11 AM|LINK
could you please specifiy the line number at which you are getting error and the error details.
AWilderbeast
Member
75 Points
118 Posts
Re: statement cannot appear outside of a method body /multiline lambda warnings prohibiting telli...
Jan 27, 2011 11:22 AM|LINK
as per the screen shot, i had my mouseover "using System;"
they arent errors, they are warnings and the page has warnings under everything
look at this screen, underline with blue is warrning, the warnings consits of
tatement cannot appear outside of a method body /multiline lambda
Decleration Expected
syntax error
End of statment expected
in that order
Yasser Shaik...
Participant
872 Points
251 Posts
Re: statement cannot appear outside of a method body /multiline lambda warnings prohibiting telli...
Jan 27, 2011 11:32 AM|LINK
The code you have posted doesn't seem to have any error. However such type of errors/warning usually come when some
statement in not written inside a procedure or subroutine.
AWilderbeast
Member
75 Points
118 Posts
Re: statement cannot appear outside of a method body /multiline lambda warnings prohibiting telli...
Jan 27, 2011 12:31 PM|LINK
can you elaborate on where id need to look to stop these warnings?
with all these warnings on the page, intellisense doesnt work! :S
Bob N
Member
88 Points
72 Posts
Re: statement cannot appear outside of a method body /multiline lambda warnings prohibiting telli...
Aug 01, 2011 06:48 PM|LINK
Have you gotten this fixed? I'm having the same issue and I'm not sure what is going on.
Thanks
Bob
kannankeril
Member
12 Points
6 Posts
Re: statement cannot appear outside of a method body /multiline lambda warnings prohibiting telli...
Dec 15, 2011 07:36 PM|LINK
Had the same problem. None of the solutions here worked for me. My language was already set to C# in the ASPX file and web.config.
The solution in my case seemed to lie in excluding the ASPX & code-behind files, then compiling the project - VS complains about the missing file!
Then including the files back in cleared out the problem.