M
maya
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..
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..