Solved

Script won't work at VS2003

Posted on 2004-03-29
10
201 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
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
 
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

706 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now