How to call a javaScript function from c#

How to call a javaScript function from c#

Post by rugha rugh » Thu, 30 May 2002 16:53:49



Hello all

How can i call a javascript method
For example:
function showMessage(message){
    alert(message);

Quote:}

from c#

The javacript method is in name.aspx
and the c# code is in name.cs

Thank you

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

 
 
 

How to call a javaScript function from c#

Post by Michae » Thu, 30 May 2002 19:25:21


In the ASPX page :

<SCRIPT Language="JavaScript">
function Pop(Texte) { window.alert(Texte); }
<ASP:Literal id="UseJS" Runat="Server" EnableViewState="False" />
</SCRIPT>

In the codebehind file (page.aspx.vb), sorry it's in VB but not hard to
translate

At the beginning of the class

Protected WithEvents UseJS As System.Web.UI.WebControls.Literal

And in your Method :
UseJS.Text = "Pop('" & MyVarString & "')"

That's all



Quote:

> Hello all

> How can i call a javascript method
> For example:
> function showMessage(message){
>     alert(message);
> }
> from c#

> The javacript method is in name.aspx
> and the c# code is in name.cs

> Thank you

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!


 
 
 

How to call a javaScript function from c#

Post by Suresh » Thu, 30 May 2002 19:31:57


Hi,
    Add one dummy label(server control) and when ever u need to call the
jscript junction, assign the script block to label text property. then the
page gets load and the script block will get executed and ur alert message
will popup like

sub button1_click(byval sender as objectm, byval e as eventergs)
    label1.text = "<script
language='javascript'>showMessage('Hai')</script>"
end sub

thanks
Suresh K


Quote:

> Hello all

> How can i call a javascript method
> For example:
> function showMessage(message){
>     alert(message);
> }
> from c#

> The javacript method is in name.aspx
> and the c# code is in name.cs

> Thank you

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

 
 
 

How to call a javaScript function from c#

Post by rugha rugh » Thu, 30 May 2002 20:29:40


it worked!
Thank you very much
Regards

Rugha

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

 
 
 

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. Using C40 COMPORT?

3. How to call C# method in JavaScript function?

4. alt.utensils.spork

5. calling a javascript function from a vb function

6. The Serial Port, rel. 11, part 3/3

7. Calling a javascript function from code behind

8. Can't delete a program that I installed

9. How to call JavaSCRIPT Function in axWebBrowser?

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

11. Calling serverside function from Javascript

12. Call javascript function onload event of usercontrol

13. calling a javascript function from asp code