?
Solved

Script won't work at VS2003

Posted on 2004-03-29
10
Medium Priority
?
219 Views
Last Modified: 2010-04-06
hi there,
we got this VS 2003, I can't manage to run a script from it always the same error "CS1026: ) expected",
I can't run the most simple script for a button click "onclick"
can any1 help plz?
10x
0
Comment
Question by:orenisraeli2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 9

Expert Comment

by:lombardp
ID: 10703460
Could you post your code?
0
 
LVL 35

Expert Comment

by:YZlat
ID: 10703747
the problem is that if you are using asp.net, the button is always rendered as a submit button. In order to add an onclick event through the server code you must first cancel the postback
0
 
LVL 35

Expert Comment

by:YZlat
ID: 10703776
try adding an onClick event through the server code:

myButton.Attributes.Add("onclick","myFunction()")
0
WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

 
LVL 1

Author Comment

by:orenisraeli2000
ID: 10704844
I'm using VS203,ASP.NET,WinXP
how to I cancel postback?

well I don't know, look I'm trying with the a very simple code:

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"  %>
<HTML>
<HEAD>
<title>WebForm1</title>
</HEAD>
      <body MS_POSITIONING="GridLayout">
      <script language=javascript >
         function x(){
         writeln("fsdfds");
         }
      </script>
      <form id="Form1" method="post" runat="server">
           <asp:Button id="Button1" runat="server" Text="Button" OnClick="javascript:o();" ></asp:Button>
      </form>
      
      </body>
</HTML>
nothing work, I've tried to call the function by many variations, nothing helps...
when I put a new buton on a new page under a new project . there is no "View Client Script"
10x
0
 
LVL 35

Expert Comment

by:YZlat
ID: 10706659
get rid of  OnClick="javascript:o();" inside <asp:Button> tag

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"  %>
<HTML>
<HEAD>
<title>WebForm1</title>
</HEAD>
     <body MS_POSITIONING="GridLayout">
     <script language=javascript >
        function x(){
        writeln("fsdfds");
        }
     </script>
     <form id="Form1" method="post" runat="server">
          <asp:Button id="Button1" runat="server" Text="Button" ></asp:Button>
     </form>
     
     </body>
</HTML>

then open your code behind file -WebForm1.aspx.cs

have this line:

Button1.Attributes.Add("onclick","javascript:o();" );

inside Page_Load procedure
0
 
LVL 35

Expert Comment

by:YZlat
ID: 10706764
I'm sorry, it should be

Button1.Attributes.Add("onclick","javascript:x();" );
0
 
LVL 1

Author Comment

by:orenisraeli2000
ID: 10712404
well hi again,
if I change the button to an <input type=button ...../>
I manage to call a javascript function, but when trying to do it with <asp:button ..../>
no chance
in inlights?


PS
I guess for you efforts I increased the points
thank you
0
 
LVL 1

Author Comment

by:orenisraeli2000
ID: 10712617
msdn tells me the same for catching <asp:button...> onclick event I need to add a line
"Button1.Attributes.Add("onclick","javascript:x();" );" but doing so I get nothing there are no errors no response nothing
0
 
LVL 2

Accepted Solution

by:
kulpem earned 1500 total points
ID: 10881268
I think you just have an error or a logic problem
I know the problem.
as I see u use another file for the server side scripting, thats good. for calling these function just use "on_click=printMe" no "()" nothing.
for javascript write it on the asp page again like this "onclick=markme"
it will work
enjoy
0
 
LVL 1

Author Comment

by:orenisraeli2000
ID: 10881283
i think its better
no one ones i guess
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question