Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 30th, 2006, 12:12 AM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sramesh
Default Client Side Script Not Working

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test.aspx.vb" Inherits="Default2" %>

<!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 runat="server">
    <title>Untitled Page</title>

</head>
<body>
<script type ="text/javascript" language="javascript">
    function sayHi() {
        alert("Hi")}

</script>
    <form id="form1" runat="server" >
    <div>
        <asp:TextBox ID="TextBox1" runat="server" Style="z-index: 100; left: 239px; position: absolute;
            top: 44px" OnTextChanged ="sayHi();" AutoPostBack ="false" ></asp:TextBox>

        <asp:Button ID="Button1" runat="server" Style="z-index: 101; left: 157px; position: absolute;
            top: 47px" Text="Button" />
        <asp:Button ID="Button2" runat="server" Style="z-index: 102; left: 67px; position: absolute;
            top: 77px" Text="Button" />
        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp;
        <input id="Text1" style="z-index: 103; left: 0px; position: absolute; top: 0px" type="text" onclick="return Text1_onclick()" />

    </div>
    </form>
</body>
</html>

This is my asp page. after build i got this errors

Error 1 'sayHi' is not a member of 'ASP.test_aspx'. \\itserver\Final Latest\Asp Booking\Test.aspx 18
Error 2 Character is not valid. \\itserver\Final Latest\Asp Booking\Test.aspx 18

Whats wrong with me?

Thanks
S. Ramesh


Reply With Quote
  #2 (permalink)  
Old May 30th, 2006, 02:06 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi S. Ramesh,

Take a look at this: OnTextChanged ="sayHi();"

You're mixing up client side and server side stuff. OnTextChanged is a server side event that fires at the server when the text in the text box has changed. However, sayHi is a client side function. The compiler tries to find a server side method called sayHi which doesn't exist, hence the error you get.

There are a few ways to fix this:

1. Change OnTextChanged to onchange. onchange is a client side HTML attribute that causes a client side function to be called when the text box is changed. .NET will see that onchange is not a server side event, so it won't look for sayHi.

2. Alternatively, you can manually add the onchange behavior to the text box in the Page_Load event:

TextBox1.Attributes.Add("onchange", "sayHi();")

Hope this helps,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Reply With Quote
  #3 (permalink)  
Old July 30th, 2007, 03:40 PM
Registered User
 
Join Date: Nov 2006
Location: Oldsmar, FL, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar:

Excellent solution - I searched for an hour for a nearly identical problem and your advice was dead-on. Thanks!

Anton

Reply With Quote
  #4 (permalink)  
Old August 2nd, 2007, 03:56 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Anton,

You're welcome.....

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Client Side Script not working in DNN rpdrake BOOK: Professional DotNetNuke ASP.NET Portals ISBN: 0-7645-9563-6 2 February 27th, 2009 03:06 PM
Problem with client side script cschng Classic ASP Basics 2 May 23rd, 2005 12:43 AM
please help ping with client side script nlicata VBScript 0 June 10th, 2004 01:44 AM



All times are GMT -4. The time now is 02:24 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.