Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 18th, 2005, 04:06 AM
Registered User
 
Join Date: May 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default I can't find the error,please help me.

 I write a code like this£º

  <%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %>

<script language="c#" runat="server">
  void DisplayName(object sender,EventArgs e)
   {
      switch (CallNumber.Text)
      {
      case"123456";
        Message.Text="this phone is jack¡£";
      break;

      case"456789";
        Message.Text="this phone is tom¡£";
      break;

      default:
       Message.Text="then number you input is wrong.";
       break;
       }

   }

</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>no title</title>
</head>
<body>
<form runat="server">
  <asp:textbox ID=CallNumber runat="server"/>
  <asp:button ID=button1 OnClick="DisplayName" runat="server"/>
  <br><br>
  <asp:label ID=Message runat="server"/>
</form>
</body>
</html>

but the Wrong suggestion


Server Error in '/' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1003: Syntax error, ':' expected

Source Error:



Line 6: switch (CallNumber.Text)
Line 7: {
Line 8: case"123456";
Line 9: Message.Text="this phone is jack¡£";
Line 10: break;

I can't find the error. anybody know please tell me.thank you


 
Old June 19th, 2005, 08:52 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

All your cases should end with : (as the error indicates).

     switch (CallNumber.Text)
      {
      case"123456":
        Message.Text="this phone is jack¡£";
      break;

      case"456789":
        Message.Text="this phone is tom¡£";
      break;

      default:
       Message.Text="then number you input is wrong.";
       break;
       }

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Find with overflow error EricB123 Excel VBA 0 July 20th, 2007 10:34 AM
Can not find server or dns error a_afiaax Classic ASP Components 0 January 18th, 2006 12:15 PM
cannot find server error jainnid General .NET 0 September 27th, 2005 09:11 AM
Error in script but can't find what's wrong!! BramuS ASP.NET 1.0 and 1.1 Basics 1 May 10th, 2005 04:32 AM
can not find form1 specified error sadiku ASP.NET 2.0 Basics 1 October 8th, 2004 05:28 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.