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 July 14th, 2006, 01:24 AM
Registered User
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to gajee Send a message via Yahoo to gajee
Default What is wrong in this code?

Hello guys.......can somebody please tell me why this ASP.NET page isnt working.........the page when run is giving me an error, specifically

---> "submitbtn_click" is undefined.

<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@Import Namespace="System"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="C#" runat="server">
void SubmitBtn_Click(Object Source,EventArgs e)
{
    spanMessage.InnerHtml = GetFormattedDate(sugg.Value);
}
</script>
<script language="C#" runat="server">
public static String GetFormattedDate(string cChoice)
{
    string sReturn;
    switch(cChoice.ToString())
    {
        case "0": sReturn=DateTime.Now.ToShortDateString();
                  break;
        case "1": sReturn=DateTime.Now.ToShortTimeString();
                  break;
        case "2": sReturn=DateTime.Now.DayOfWeek.ToString();
                  break;
        case "3": sReturn=DateTime.Now.ToString();
                  break;
        default: sReturn ="None";
                  break;
    }
    return sReturn;
}
</script>
</head>
<body>
</body>
</html>
<form id="formConvert" runat="server">
  <select ID="sugg" runat="server">
  <option value="0">Short Date</option>
    <option value="1">Short Time</option>
      <option value="2">Day of the Week</option>
        <option value="3">Date and Time</option>
  </select>
  <input type="Submit" value="Submit" onClick="SubmitBtn_Click" runat="server"/>
 <SPAN ID="spanMessage" runat="server"/>
</form>


 
Old July 14th, 2006, 01:33 AM
Registered User
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to gajee Send a message via Yahoo to gajee
Default

The error code is shown in the Browser

--> SubmitBtn_click is undefined <--

I am a newbie to ASP.NET...help would be very much appreciated.....

 
Old July 14th, 2006, 06:41 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Remove your onClick method from the buttons code in your <script> tag after the method add this:

(VB)
Private sub SubmitBtn_Click(byVal s as object, byVal e as eventArgs) handles SubmitBtn.Click
End Sub


"The one language all programmers understand is profanity."





Similar Threads
Thread Thread Starter Forum Replies Last Post
what's wrong with my code? DyerOppenheimer BOOK: Beginning Ajax with ASP.NET 0 January 7th, 2008 08:46 AM
What's wrong with this code? appleseed C++ Programming 2 November 25th, 2006 08:17 AM
What's wrong with this code? AlDugan XSLT 3 May 19th, 2006 12:06 PM
What is wrong with code? rtr1900 Classic ASP Databases 1 April 3rd, 2006 03:20 AM
what's wrong with this code? miguel.ossa ASP.NET 1.0 and 1.1 Basics 2 January 21st, 2004 11:33 AM





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