473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Why do I get this error?

When running this code from VS.NET i get this error page which highlights the
first line of the If statement and says it needs a ; at the end of it, tried
that but doesnt fix the problem. As you can tell I'm a newbie so be gentle :)
..

Compiler Error Message: CS1002: ; expected

void btnSingIn_Click(Object sender, System.EventArgs e)
{
// Add user authentication logic here
If (txtUserId.Text.Length >= 4 && txtPassword.Text.Length >= 4 &&
txtUserId.Text.StartsWith("J"))
{
lblResult.Text = "Valid User!";
}
else
{
lblResult.Text = "Valid User!";
}
}

void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialise the page here
lblResult.Text = "Page refreshed at: " + DateTime.Now;
}


Nov 18 '05 #1
4 1239
Hi Ken,

It doesn't look like the posted code has anything wrong. Do you have some
code inlined into the .aspx file also? You're getting the compilation error
when trying to browse the page right? and not when building inside VS.NET?

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://clariusconsulting.net/vga
My profile: http://aspnet2.com/mvp.ashx?vga
"ken.r" <Ke***@discussions.microsoft.com> wrote in message
news:CD**********************************@microsof t.com...
When running this code from VS.NET i get this error page which highlights
the
first line of the If statement and says it needs a ; at the end of it,
tried
that but doesnt fix the problem. As you can tell I'm a newbie so be gentle
:)
.

Compiler Error Message: CS1002: ; expected

void btnSingIn_Click(Object sender, System.EventArgs e)
{
// Add user authentication logic here
If (txtUserId.Text.Length >= 4 && txtPassword.Text.Length >= 4 &&
txtUserId.Text.StartsWith("J"))
{
lblResult.Text = "Valid User!";
}
else
{
lblResult.Text = "Valid User!";
}
}

void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialise the page here
lblResult.Text = "Page refreshed at: " + DateTime.Now;
}

Nov 18 '05 #2
ken.r wrote:
When running this code from VS.NET i get this error page which highlights the
first line of the If statement and says it needs a ; at the end of it, tried
that but doesnt fix the problem. As you can tell I'm a newbie so be gentle :)
.
The problem is your "If" statement. It should be "if" (lowercase). It
thinks you wrote a function called If().
Compiler Error Message: CS1002: ; expected

void btnSingIn_Click(Object sender, System.EventArgs e)
{
// Add user authentication logic here
If (txtUserId.Text.Length >= 4 && txtPassword.Text.Length >= 4 &&
txtUserId.Text.StartsWith("J"))
{
lblResult.Text = "Valid User!";
}
else
{
lblResult.Text = "Valid User!";
}
}

void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialise the page here
lblResult.Text = "Page refreshed at: " + DateTime.Now;
}

Nov 18 '05 #3
Victor Garcia Aprea [MVP] wrote:
Hi Ken,

It doesn't look like the posted code has anything wrong. Do you have some
code inlined into the .aspx file also? You're getting the compilation error
when trying to browse the page right? and not when building inside VS.NET?


Sure there is. He's writing "If" instead of "if".

Nov 18 '05 #4
Thanks for that, greatly appreciated :)
regards
Ken

"Ryan Walberg, MCSD for .NET" wrote:
ken.r wrote:
When running this code from VS.NET i get this error page which highlights the
first line of the If statement and says it needs a ; at the end of it, tried
that but doesnt fix the problem. As you can tell I'm a newbie so be gentle :)
.


The problem is your "If" statement. It should be "if" (lowercase). It
thinks you wrote a function called If().
Compiler Error Message: CS1002: ; expected

void btnSingIn_Click(Object sender, System.EventArgs e)
{
// Add user authentication logic here
If (txtUserId.Text.Length >= 4 && txtPassword.Text.Length >= 4 &&
txtUserId.Text.StartsWith("J"))
{
lblResult.Text = "Valid User!";
}
else
{
lblResult.Text = "Valid User!";
}
}

void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialise the page here
lblResult.Text = "Page refreshed at: " + DateTime.Now;
}

Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andrew Luke | last post by:
Hi all you C++ guru's! I'm 'very, very' new to C++ and I'm having a little trouble configuring my VS environment I think - when I try and compile some sample code I'm getting the following...
1
by: Minh | last post by:
I've just installed VS.NET 2003 on my Athlon XP 1800+. However I couldn't get any project with STL includes to compile even if I create a new empty project (and added #include <string>). It gave me...
3
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
4
by: Sanjay Kumar | last post by:
Folks ! I am working with VC++ after a long time and having problem linking latest xerces 2.7 in VC++ 2005 Express Edition. I have done following: 1. downloaded and unpacked the the...
1
by: developer | last post by:
Hi All I have made a .NET project. the files included are borland c++ files that i am migrate to VC++ .NET I am using Microsoft Visual C++ .NET 2003. the compilation goes through properly,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.