Solved

Script won't work at VS2003

Posted on 2004-03-29
10
212 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What is the normal amount of queries 5 89
JQuery tracking event. 3 89
Problem to page 4 103
Questions about this React unit test 4 75
There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

739 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