Showing posts with label line. Show all posts
Showing posts with label line. Show all posts

Saturday, March 31, 2012

Strange "expected ;" error

I am getting an error and I can't seem to figure out why. The error is on line 32.

Compiler Error Message: CS1002: ; expected

Line 30: strScriptName=Request.ServerVariables("SCRIPT_NAME");
Line 31: strFolder="/buildlauncher/";
Line 32: If (strScriptName.IndexOf(strFolder)=-1)
Line 33: {
Line 34: strbuildlauncher="class='selected'";

The language I am using is C# and I don't seem to understand what a ; would be doing in an if statement. What I am trying to do is determine if the folder specified in the strFolder variable is in the server variable SCRIPT_NAME.There are some syntax problems here:

If (strScriptName.IndexOf(strFolder)=-1)

should probably be

if(strScriptName.IndexOf(strFolder) == -1)

Note the case sensitivity and the equality operator.

Strange and annoying problem

Even commenting a line in javascript still prompts for an error. If I remove the following line then no error, but again if i put it back, even commented error occurs.

//opener.document.getElementById('<%=TextBox1.ClientID%>').value='akberalikaka';

isn't it strange behavior

Yes it is strange. As far as i am aware of, there are three types of comment you can do in java:

1. Multiple-line :/* and*/

2.One-line comments of C++ style: Begins with // and continue up to the next line break:

3.One-line comments with theHTML comment-opening sequence (<!--). Note that the JavaScript interpreter ignores the closing characters of HTML comments (-->). Consider this example:
<!-- This is treated as a one-line JS comment<!-- It works just like a comment beginning with //<!-- --> This is also a one-line JS comment<!-- --> because JS ignores the closing characters<!-- --> of HTML-style comments

HTML-style comments are not usually found in the middle of JavaScript code. However, it is recommended to use HTML comments for hiding Javascript code from old browsers

Try using this mate


Hi,

//opener.document.getElementById('<%=TextBox1.ClientID%>').value='akberalikaka';

Your comment in javascript doesn't stop<%=TextBox1.ClientID%> since it is asp.net code. So to clear the error you have to remove this code.


You have to comment the aspnet code also

if you are using C#

//opener.document.getElementById('<%/*=TextBox1.ClientID*/%>').value='akberalikaka';

if you are using VB

//opener.document.getElementById('<%'=TextBox1.ClientID'%>').value='akberalikaka';

<%'=TextBox1.ClientID'%> is equivalent to <% Response.Write(TextBox1.ClientID) %>

Wednesday, March 28, 2012

Strange character transformations

Hi,

I have an ASP.Net website, which allows users to upload a file which is
then inserted into a database.

This is all fine until it reads a line with the string +Anu in it.
It transforms this to this char ? (which, if Googled for, is
described as Unicode Character 'LATIN SMALL LETTER TURNED R WITH HOOK'
(U+027B) or, in Phonetics, as a 'Retroflex approximant'.)

Has anyone seen this behaviour before, and know how to stop it?
The code's simple - here's an example. The ? appears in the output
where the input is +Anu - it's transformed before I can touch it!

using (StreamReader sr = new StreamReader(strFile,
System.Text.Encoding.UTF7)) {
// Read and display lines from the file until the end of the file is
reached.
while ((line = sr.ReadLine()) != null) {
Response.Write(line);
}
}

Regards

AdamLooks like an encoding issue, alright.
Have you tried using the StreamReader constructor that does not require a
character encoding?

"CyberSpyders@.gmail.com" wrote:

Quote:

Originally Posted by

Hi,
>
I have an ASP.Net website, which allows users to upload a file which is
then inserted into a database.
>
This is all fine until it reads a line with the string +Anu in it.
It transforms this to this char ? (which, if Googled for, is
described as Unicode Character 'LATIN SMALL LETTER TURNED R WITH HOOK'
(U+027B) or, in Phonetics, as a 'Retroflex approximant'.)
>
Has anyone seen this behaviour before, and know how to stop it?
The code's simple - here's an example. The ? appears in the output
where the input is +Anu - it's transformed before I can touch it!
>
using (StreamReader sr = new StreamReader(strFile,
System.Text.Encoding.UTF7)) {
// Read and display lines from the file until the end of the file is
reached.
while ((line = sr.ReadLine()) != null) {
Response.Write(line);
}
}
>
Regards
>
Adam
>
>


Graven,

I'm not sure how a 4 letter string like this could be seen as an
encoding issue, but I will certainly give it a go. Thanks for the
suggestion.

Adam

Graven wrote:

Quote:

Originally Posted by

Try to use plain latin-1 encoding. I think it's an unicode
normalization issue, but don't know if StreamReader performs it by
default.
>
>
CyberSpyders@.gmail.com wrote:

Quote:

Originally Posted by

Hi,

I have an ASP.Net website, which allows users to upload a file which is
then inserted into a database.

This is all fine until it reads a line with the string +Anu in it.
It transforms this to this char ? (which, if Googled for, is
described as Unicode Character 'LATIN SMALL LETTER TURNED R WITH HOOK'
(U+027B) or, in Phonetics, as a 'Retroflex approximant'.)

Has anyone seen this behaviour before, and know how to stop it?
The code's simple - here's an example. The ? appears in the output
where the input is +Anu - it's transformed before I can touch it!

using (StreamReader sr = new StreamReader(strFile,
System.Text.Encoding.UTF7)) {
// Read and display lines from the file until the end of the file is
reached.
while ((line = sr.ReadLine()) != null) {
Response.Write(line);
}
}

Regards

Adam


Larry,

You were spot on - changing to UTF8 stopped this transformation. Thanks

It's not quite solved my problem though.
The file is a Text file, each line being a series of files delimited by
the character, as this was unliekley to ever appear in the actual
data.

Unfortunately, UTF8 encoding strips these characters completely. ASCII
encoding, on the other hand, replaces them with ?

Oh the joy of character encoding.

Regards

Adam

Larry Lard wrote:

Quote:

Originally Posted by

This is why you are seeing what you are seeing. UTF7 encodes characters
outside the printable 7 bit range using UTF16 then modified base64, with
+ as the indicator mark for this encoding. I haven't checked, but I
imagine +Anu is the UTF7 encoding of that character. You shouldn't use a
UTF7 reader to read a file that you don't know for sure was produced by
a UTF7 writer.
>
The correct way to read the file depends on what kind of file it is. If
it is text of an unknown encoding, there is no way to be absolutely
sure, but UTF8 is a good starting point. If it's binary data, you
shouldn't be using a TextReader class at all.

strange compile error!

Hey

asp.net 2.0

This line of code:

MembershipUserCollection onlineUsers = Membership.GetAllUsers;

In this script:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MasterPages_ContentMaster : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
MembershipUserCollection onlineUsers = Membership.GetAllUsers;
}
}
}

Gives this compile error:
Error 2 Cannot convert method group 'GetAllUsers' to non-delegate type
'System.Web.Security.MembershipUserCollection'. Did you intend to invoke the
method? C:\Documents and Settings\Jeff\My Documents\Visual Studio
2005\WebSites\Helloworld\MasterPages\ContentMaster .master.cs 20 52
C:\...\Helloworld\

The code is placed in a master page...

I don't understand what I'm doing wrong here...

Any suggestions?Its a method, you need some parenthesis there.
http://msdn2.microsoft.com/en-us/library/dy8swhya.aspx
Jeff wrote:

Quote:

Originally Posted by

Hey
>
asp.net 2.0
>
This line of code:
>
MembershipUserCollection onlineUsers = Membership.GetAllUsers;
>
In this script:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
>
public partial class MasterPages_ContentMaster : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
MembershipUserCollection onlineUsers = Membership.GetAllUsers;
}
}
}
>
Gives this compile error:
Error 2 Cannot convert method group 'GetAllUsers' to non-delegate type
'System.Web.Security.MembershipUserCollection'. Did you intend to invoke the
method? C:\Documents and Settings\Jeff\My Documents\Visual Studio
2005\WebSites\Helloworld\MasterPages\ContentMaster .master.cs 20 52
C:\...\Helloworld\
>
The code is placed in a master page...
>
I don't understand what I'm doing wrong here...
>
Any suggestions?


"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:eKM4DMM7GHA.1496@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

This line of code:
MembershipUserCollection onlineUsers = Membership.GetAllUsers;


Quote:

Originally Posted by

Gives this compile error:
Error 2 Cannot convert method group 'GetAllUsers' to non-delegate type


[...]

You're going to laugh (or cry):
MembershipUserCollection onlineUsers = Membership.GetAllUsers();

Having that "()" there is what you need. This drove me nuts for a while, as
VB.Net doesn't need it and I got in the habit of omitting it.

--
Chris Mullins, MCSD.NET, MCPD:Enterprise
http://www.coversant.net/blogs/cmullins
solved, GetAllUsers is a method, not a property...

"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:eKM4DMM7GHA.1496@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

Hey
>
asp.net 2.0
>
This line of code:
>
MembershipUserCollection onlineUsers = Membership.GetAllUsers;
>
In this script:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
>
public partial class MasterPages_ContentMaster : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
MembershipUserCollection onlineUsers = Membership.GetAllUsers;
}
}
}
>
Gives this compile error:
Error 2 Cannot convert method group 'GetAllUsers' to non-delegate type
'System.Web.Security.MembershipUserCollection'. Did you intend to invoke
the method? C:\Documents and Settings\Jeff\My Documents\Visual Studio
2005\WebSites\Helloworld\MasterPages\ContentMaster .master.cs 20 52
C:\...\Helloworld\
>
The code is placed in a master page...
>
I don't understand what I'm doing wrong here...
>
Any suggestions?
>

strange compile error!

Hey
asp.net 2.0
This line of code:
MembershipUserCollection onlineUsers = Membership.GetAllUsers;
In this script:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class MasterPages_ContentMaster : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
MembershipUserCollection onlineUsers = Membership.GetAllUsers;
}
}
}
Gives this compile error:
Error 2 Cannot convert method group 'GetAllUsers' to non-delegate type
'System.Web.Security.MembershipUserCollection'. Did you intend to invoke the
method? C:\Documents and Settings\Jeff\My Documents\Visual Studio
2005\WebSites\Helloworld\MasterPages\Con
tentMaster.master.cs 20 52
C:\...\Helloworld\
The code is placed in a master page...
I don't understand what I'm doing wrong here...
Any suggestions?Its a method, you need some parenthesis there.
http://msdn2.microsoft.com/en-us/library/dy8swhya.aspx
Jeff wrote:
> Hey
> asp.net 2.0
> This line of code:
> MembershipUserCollection onlineUsers = Membership.GetAllUsers;
> In this script:
> using System;
> using System.Data;
> using System.Configuration;
> using System.Collections;
> using System.Web;
> using System.Web.Security;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Web.UI.WebControls.WebParts;
> using System.Web.UI.HtmlControls;
> public partial class MasterPages_ContentMaster : System.Web.UI.MasterPage
> {
> protected void Page_Load(object sender, EventArgs e)
> {
> if (!this.IsPostBack)
> {
> MembershipUserCollection onlineUsers = Membership.GetAllUsers;
> }
> }
> }
> Gives this compile error:
> Error 2 Cannot convert method group 'GetAllUsers' to non-delegate type
> 'System.Web.Security.MembershipUserCollection'. Did you intend to invoke t
he
> method? C:\Documents and Settings\Jeff\My Documents\Visual Studio
> 2005\WebSites\Helloworld\MasterPages\Con
tentMaster.master.cs 20 52
> C:\...\Helloworld\
> The code is placed in a master page...
> I don't understand what I'm doing wrong here...
> Any suggestions?
"Jeff" <it_consultant1@.hotmail.com.NOSPAM> wrote in message
news:eKM4DMM7GHA.1496@.TK2MSFTNGP05.phx.gbl...
> This line of code:
> MembershipUserCollection onlineUsers = Membership.GetAllUsers;

> Gives this compile error:
> Error 2 Cannot convert method group 'GetAllUsers' to non-delegate type
[...]
You're going to laugh (or cry):
MembershipUserCollection onlineUsers = Membership.GetAllUsers();
Having that "()" there is what you need. This drove me nuts for a while, as
VB.Net doesn't need it and I got in the habit of omitting it.
Chris Mullins, MCSD.NET, MCPD:Enterprise
http://www.coversant.net/blogs/cmullins
solved, GetAllUsers is a method, not a property...
"Jeff" <it_consultant1@.hotmail.com.NOSPAM> wrote in message
news:eKM4DMM7GHA.1496@.TK2MSFTNGP05.phx.gbl...
> Hey
> asp.net 2.0
> This line of code:
> MembershipUserCollection onlineUsers = Membership.GetAllUsers;
> In this script:
> using System;
> using System.Data;
> using System.Configuration;
> using System.Collections;
> using System.Web;
> using System.Web.Security;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Web.UI.WebControls.WebParts;
> using System.Web.UI.HtmlControls;
> public partial class MasterPages_ContentMaster : System.Web.UI.MasterPage
> {
> protected void Page_Load(object sender, EventArgs e)
> {
> if (!this.IsPostBack)
> {
> MembershipUserCollection onlineUsers = Membership.GetAllUsers;
> }
> }
> }
> Gives this compile error:
> Error 2 Cannot convert method group 'GetAllUsers' to non-delegate type
> 'System.Web.Security.MembershipUserCollection'. Did you intend to invoke
> the method? C:\Documents and Settings\Jeff\My Documents\Visual Studio
> 2005\WebSites\Helloworld\MasterPages\Con
tentMaster.master.cs 20 52
> C:\...\Helloworld\
> The code is placed in a master page...
> I don't understand what I'm doing wrong here...
> Any suggestions?
>

Saturday, March 24, 2012

strange error in a very simple method - what is wrong with asp.net?

Hello,

I have a simple method, which looks from my point of view entirely correct, but I
get the error:

;expected (in the line of declaration, CreateDataTable is red underlined )

The code is the following:

private void DataTable CreateDataTable(string selection){
int maxrowindex;

switch (selection)
{
case "newtable" :

DataColumn myDataColumn;
DataRow myDataRow;
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.Int32");
myDataColumn.ColumnName = "id";
myDataColumn.ReadOnly = false;
myDataColumn.Unique = true;
myDataTable.Columns.Add(myDataColumn);

myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.String");
myDataColumn.ColumnName = "Material";
myDataColumn.AutoIncrement = false;
myDataColumn.Caption = "Material";
myDataColumn.ReadOnly = false;
myDataColumn.Unique = false;
myDataTable.Columns.Add(myDataColumn);

myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.Int32");
myDataColumn.ColumnName = "Amount";
myDataColumn.AutoIncrement = false;
myDataColumn.Caption = "Amount";
myDataColumn.ReadOnly = false;
myDataColumn.Unique = false;
myDataTable.Columns.Add(myDataColumn);

DataColumn[] PrimaryKeyColumns = new DataColumn[1];
PrimaryKeyColumns[0] = myDataTable.Columns["id"];
myDataTable.PrimaryKey = PrimaryKeyColumns;

//myDataSet = new DataSet();
//myDataSet.Tables.Add(myDataTable);

myDataRow = myDataTable.NewRow();
myDataRow["id"] = 1;
myDataRow["Material"] = "Bezeichnung ";
myDataRow["Amount"] = 0;
myDataTable.Rows.Add(myDataRow);
maxrowindex = 1;

break;

case "newrow" :

break;

case "deleterow" :
break;
}

}


Does anybody know what is wrong?void or DataTable, pick one.
thanks!

Strange execution,it is like not all lines are executed.

Hi,
I have this code and I have the impresion that all the lines are not exectuted it's like it jumps from line 10 to 14, even when I execute it step by step.
My oUserList Objects is equals nothing when I pass the mouse over it.
Sb has had this problem before?
The error I have is:
System.NullReferenceException: Object reference not set to an instance of an object.
(line 16)

Thanks


1 Public Class UserLendings
2 Inherits System.Web.UI.Page
3 Protected WithEvents DrlUser As System.Web.UI.WebControls.DropDownList
3 Protected WithEvents btnExec As System.Web.UI.WebControls.Button
5 Dim oUserList As New clsUserList()
6 Dim oUser As New clsUser()
7 Protected WithEvents grdProducts As System.Web.UI.WebControls.DataGrid
8 Dim cProductList As New Collection()
9 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
10 If Not IsPostBack Then 'Put user code to initialize the page here
11 DrlUser.DataSource = oUserList.GetAllUsers
12 DrlUser.DataValueField = "userid"
13 DrlUser.DataTextField = "userName"
14 DrlUser.DataBind()
15 DrlUser.SelectedIndex = 0
16 End If
17 End Sub

I have had something similar happen to me. If you are referencing this class from another project and you reference it from the obj folder ( like obj\debug ) rather than the bin folder and you have added code to the class, then you need to rebuild the class before you try to run the project that references the class. Otherwise, it will jump over the code that you have added since your last rebuild.

If you just hit F5 and have the system automatically rebuild the projects before running\debugging, you still have this problem. You have to manually tell the system to rebuild the class.

Hope this helps.
MajorCats