Solved

Script won't work at VS2003

Posted on 2004-03-29
10
216 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
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 
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 500 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

696 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