calling a simple javascript function from a webform control

calling a simple javascript function from a webform control

Post by Dave Kekis » Fri, 03 Aug 2001 04:27:41



This is probably a dumb question but here goes.  I am attempting to kick off
a javascript function from the onClick event on an asp:Button.  When i write
it the way i am used to writing it, i get the following output.   Any Ideas?

Compilation Error

Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30456: The name 'test' is not a member of
'ASP.WebForm1_aspx'.

Source Error:

Line 11: <body MS_POSITIONING="GridLayout">

Line 12: <form id="Form1" method="post" runat="server">

Line 13: <asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 279px;
POSITION: absolute; TOP: 86px" runat="server" Text="Button" Width="247px"
Height="43px" OnClick="test();"></asp:Button>

Line 14: </form>

Line 15: <script language="javascript">

Line 16: function test() {

Line 17: alert();

Line 18: }

Line 19: </script>

Source File: c:\inetpub\wwwroot\WebA\WebForm1.aspx Line: 13

 
 
 

calling a simple javascript function from a webform control

Post by Radomir (MS » Fri, 03 Aug 2001 05:18:01


instead of this, try the following:

  -- remove OnClick from the button

  -- add the following client-side script:

  <script for=Button1 event=onclick>
    alert ("Client-side onclick");
  </script>

hope this helps.

 
 
 

calling a simple javascript function from a webform control

Post by Chuck Lazar » Fri, 03 Aug 2001 05:24:44


Try adding "runat=server" to your script tag to
differentiate your script as server-side vs client-side.

<script language="javascript" runat=server>...

-Chuck

Quote:>-----Original Message-----
>This is probably a dumb question but here goes.  I am

attempting to kick off
Quote:>a javascript function from the onClick event on an

asp:Button.  When i write
Quote:>it the way i am used to writing it, i get the following

output.   Any Ideas?
Quote:

>Compilation Error

>Description: An error occurred during the compilation of
a resource required
>to service this request. Please review the following

specific error details
Quote:>and modify your source code appropriately.

>Compiler Error Message: BC30456: The name 'test' is not a
member of
>'ASP.WebForm1_aspx'.

>Source Error:

>Line 11: <body MS_POSITIONING="GridLayout">

>Line 12: <form id="Form1" method="post" runat="server">

>Line 13: <asp:Button id="Button1" style="Z-INDEX: 101;
LEFT: 279px;
>POSITION: absolute; TOP: 86px" runat="server"

Text="Button" Width="247px"

- Show quoted text -

Quote:>Height="43px" OnClick="test();"></asp:Button>

>Line 14: </form>

>Line 15: <script language="javascript">

>Line 16: function test() {

>Line 17: alert();

>Line 18: }

>Line 19: </script>

>Source File: c:\inetpub\wwwroot\WebA\WebForm1.aspx Line:
13

>.

 
 
 

calling a simple javascript function from a webform control

Post by Victor Garcia Apre » Fri, 03 Aug 2001 07:26:05


If the Javascript function you are going to call is going to be generated
based on some server-side processing you may want to generate the
client-side code in the server-side by using a LiteralControl with the
script code,

-Victor.


Quote:> This is probably a dumb question but here goes.  I am attempting to kick
off
> a javascript function from the onClick event on an asp:Button.  When i
write
> it the way i am used to writing it, i get the following output.   Any
Ideas?

> Compilation Error

> Description: An error occurred during the compilation of a resource
required
> to service this request. Please review the following specific error
details
> and modify your source code appropriately.

> Compiler Error Message: BC30456: The name 'test' is not a member of
> 'ASP.WebForm1_aspx'.

> Source Error:

> Line 11: <body MS_POSITIONING="GridLayout">

> Line 12: <form id="Form1" method="post" runat="server">

> Line 13: <asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 279px;
> POSITION: absolute; TOP: 86px" runat="server" Text="Button" Width="247px"
> Height="43px" OnClick="test();"></asp:Button>

> Line 14: </form>

> Line 15: <script language="javascript">

> Line 16: function test() {

> Line 17: alert();

> Line 18: }

> Line 19: </script>

> Source File: c:\inetpub\wwwroot\WebA\WebForm1.aspx Line: 13

 
 
 

1. I want to call a javascript function WITH parameters function from c#

I want to call a javascript function WITH parameters function from c#
code; I already did this:
....
StartDate.Attributes.Add("onTextChange","DateGreaterThan(" +
StartDate.Value + "," + RequiredByDate.Value + ");");
....
in the control (C# code)

What is the syntax to call the function from asp.net?
this does not work:
<combo:WebDateChooser id="StartDate" runat="server"
onValueChange="DateGreaterThan(Date2, Date1);"></combo:WebDateChooser>

this is the function in javascript:

function DateGreaterThan(Date2,Date1)
{ ....}

2. Maybe OFF Topic - FTP Directory Size

3. Call javascript from a webform control

4. Job Role: VB6 Developer / Programmer ( 5 Positions), Work Location : Pittsburgh, PA, Duration: 6 Months Minimum ( Please respond at vikramjits@universal-sw.com / 603-324-4008)

5. calling a javascript function from a vb function

6. 200 of the Top windows based terminals

7. Calling simple javascript from codebehind???

8. JDBC related question.

9. Client side DHTML javascript call webform methods or events

10. Calling a javascript function from code behind

11. How to call JavaSCRIPT Function in axWebBrowser?

12. Can JavaScript call c++ functions defined in an MFC-based browser app?

13. Calling serverside function from Javascript