PC Review


Reply
Thread Tools Rate Thread

compiler error msg..

 
 
maya
Guest
Posts: n/a
 
      21st Jul 2006
am following "asp.NET Unleashed", by Stephen Walther (a SAMS book..
covers .net 1.1 though..)

on one of his examples (ch 2) am getting compilation error.. code:

<script Runat="Server">
void ChangeBox1( object s, EventArgs e ) {
txtBox1 = StrReverse( txtBox1 );
CheckWin();
}
void ChangeBox3( object s, EventArgs e ) {
txtBox3 = StrReverse( txtBox3 );
CheckWin();
}
void CheckWin() {
if ( txtBox1 == "Apple" && txtBox2 == "Apple" && txtBox3 == "Apple" )
lblMessage = "You Win!";
}
public string StrReverse(string strString) {
char[] strArray = strString.ToCharArray();
Array.Reverse(strArray);
return new String(strArray);
}
</script>
<html>
<body>
<form Runat="Server">
Enter the word Apple into all three TextBoxes:<br><br>
<asp:TextBox ID="txtBox1" AutoPostBack="True"
OnTextChanged="ChangeBox3" Runat="Server"/>
<asp:TextBox ID="txtBox2" AutoPostBack="True"
OnTextChanged="ChangeBox1" Runat="Server"/>
<asp:TextBox ID="txtBox3" AutoPostBack="True"
OnTextChanged="ChangeBox3" Runat="Server"/>
<asp:Label ID="lblMessage" Runat="Server" />
</form>
</body>
</html>


error:

Compiler Error Message: CS1502: The best overloaded method match for
'ASP.Game_aspx.StrReverse(string)' has some invalid arguments

Source Error:

Line 2: <script Runat="Server">
Line 3: void ChangeBox1( object s, EventArgs e ) {
Line 4: txtBox1 = StrReverse( txtBox1 );
Line 5: CheckWin();
Line 6: }


I know StrReverse is a method that exists already in FCL
(http://msdn2.microsoft.com/en-us/library/8ycf85wx.aspx), and
"overloaded" error probably has to do with this (I renamed StrReverse
method, but got same error.. in Java you never give a method you
declare a name of a method that exists already in API..(??) )

also in StrReverse method decl. I noticed 'string' is in lower case, is
this right? in Java it would be

public string StrReverse(String strString)" (upper case 'string'..)
(did try changing it to uppercase, got same compilation error..)

would appreciate suggestions/enlightenment.. many thanks..


 
Reply With Quote
 
 
 
 
Roger
Guest
Posts: n/a
 
      21st Jul 2006
Hi maya,
I think your error is that you should be using
the .Text property (a String) of the TextBox
(txtBox1). And pass that to StrReverse.
Roger


TextBoxes:<br><br>
> <asp:TextBox ID="txtBox1" AutoPostBack="True"
> error:
>
> Compiler Error Message: CS1502: The best overloaded method match for
> 'ASP.Game_aspx.StrReverse(string)' has some invalid arguments
>
> Source Error:
>
> Line 2: <script Runat="Server">
> Line 3: void ChangeBox1( object s, EventArgs e ) {
> Line 4: txtBox1 = StrReverse( txtBox1 );
> Line 5: CheckWin();
> Line 6: }
>
>



 
Reply With Quote
 
maya
Guest
Posts: n/a
 
      24th Jul 2006
thank you Roger.. ok, this is what I did now:

<script Runat="Server">
void ChangeBox1( object s, EventArgs e ) {
string one = txtBox1.Text;
StrReverse( one );
CheckWin();
}
void ChangeBox3( object s, EventArgs e ) {
string three = txtBox3.Text;
StrReverse( three );
CheckWin();
}
void CheckWin() {
if ( one == "Apple" && txtBox2.Text == "Apple" && three == "Apple" )
lblMessage = "You Win!";
}
public string StrReverse(string strString) {
char[] strArray = strString.ToCharArray();
Array.Reverse(strArray);
return new String(strArray);
}

but still get error:

Compiler Error Message: CS0103: The name 'one' does not exist in the
class or namespace 'ASP.Game_aspx'

Source Error:
Line 13: void CheckWin() {
Line 14: if ( one == "Apple" && txtBox2.Text == "Apple" && three ==
"Apple" )
Line 15: lblMessage = "You Win!";

and now am getting this error:

Cannot implicitly convert type 'string' to
'System.Web.UI.WebControls.Label'

don't get this.. do you have to put word 'string' when you declare a
string or not? took out word 'string' from string declarations, and now
get this error:

The name 'one' does not exist in the class or namespace 'ASP.gameA_aspx'

thank you...



Roger wrote:
> Hi maya,
> I think your error is that you should be using
> the .Text property (a String) of the TextBox
> (txtBox1). And pass that to StrReverse.
> Roger
>
>
> TextBoxes:<br><br>
>> <asp:TextBox ID="txtBox1" AutoPostBack="True"
>> error:
>>
>> Compiler Error Message: CS1502: The best overloaded method match for
>> 'ASP.Game_aspx.StrReverse(string)' has some invalid arguments
>>
>> Source Error:
>>
>> Line 2: <script Runat="Server">
>> Line 3: void ChangeBox1( object s, EventArgs e ) {
>> Line 4: txtBox1 = StrReverse( txtBox1 );
>> Line 5: CheckWin();
>> Line 6: }
>>
>>

>
>

 
Reply With Quote
 
Roger
Guest
Posts: n/a
 
      24th Jul 2006
> Compiler Error Message: CS0103: The name 'one' >does not exist in the

This is because it is defined as a local variable,
widen it's scope.

> <script Runat="Server">
> void ChangeBox1( object s, EventArgs e ) {
> string one = txtBox1.Text;
> StrReverse( one );
> CheckWin();




> if ( one == "Apple" && txtBox2.Text == "Apple" && three == "Apple" )
> lblMessage = "You Win!";
> }
> public string StrReverse(string strString) {
> char[] strArray = strString.ToCharArray();
> Array.Reverse(strArray);
> return new String(strArray);
> }
>
> but still get error:
>
> class or namespace 'ASP.Game_aspx'
>
> Source Error:
> Line 13: void CheckWin() {
> Line 14: if ( one == "Apple" && txtBox2.Text == "Apple" && three ==
> "Apple" )
> Line 15: lblMessage = "You Win!";
>
> and now am getting this error:
>
> Cannot implicitly convert type 'string' to
> 'System.Web.UI.WebControls.Label'
>
> don't get this.. do you have to put word 'string' when you declare a
> string or not? took out word 'string' from string declarations, and now
> get this error:
>
> The name 'one' does not exist in the class or namespace

'ASP.gameA_aspx'
>
> thank you...
>
>
>
> Roger wrote:
> > Hi maya,
> > I think your error is that you should be using
> > the .Text property (a String) of the TextBox
> > (txtBox1). And pass that to StrReverse.
> > Roger
> >
> >
> > TextBoxes:<br><br>
> >> <asp:TextBox ID="txtBox1" AutoPostBack="True"
> >> error:
> >>
> >> Compiler Error Message: CS1502: The best overloaded method match for
> >> 'ASP.Game_aspx.StrReverse(string)' has some invalid arguments
> >>
> >> Source Error:
> >>
> >> Line 2: <script Runat="Server">
> >> Line 3: void ChangeBox1( object s, EventArgs e ) {
> >> Line 4: txtBox1 = StrReverse( txtBox1 );
> >> Line 5: CheckWin();
> >> Line 6: }
> >>
> >>

> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Possible VS2003 c# compiler bug: error CS0584: Internal Compiler Error: stage 'COMPILE' symbol '' eblanco Microsoft Dot NET Framework 0 28th Jul 2006 09:40 PM
Compiler Error Message: The compiler failed with error code -1073741819 Ram Microsoft ASP .NET 0 13th Sep 2005 10:52 AM
fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'f:\vs70builds\3077\vc\Compiler\Utc\src\P2\main.c', line 148) PufferFish Microsoft VC .NET 10 6th Aug 2004 10:33 PM
fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 2701) =?Utf-8?B?TWFyY28gTm92YQ==?= Microsoft VC .NET 9 27th Apr 2004 06:55 PM
Compiler Error Message: The compiler failed with error code 128. Yan Microsoft ASP .NET 0 21st Jul 2003 11:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:01 PM.