tags:

views:

361

answers:

1

I have the following jquery function

> <script type="text/javascript">
> 
>     $(document).ready(function() {
> 
>         $('#callGrowel').click(function() {
>             $.growlUI('Email Received', 'from Joe Bloggs');
>         });
>     });
> 
> </script>

and in my aspx page I have a div

<div id="callGrowel" >Run Growe l</div>

but I need a way of calling the growlUI jquery function from my code behind file in C# rather than clicking on a div in the UI.

Is this possible??

+1  A: 

This doesn't make sense really. Your C# code runs on the server to generate an HTML file which is passed to the client and translated there. jQuery can only operate on the HTML n the client side.

Is what you're trying to do not achieved by replacing

     $('#callGrowel').click(function() {
         $.growlUI('Email Received', 'from Joe Bloggs');
     });

with

     $.growlUI('Email Received', 'from Joe Bloggs');

?

pdr
No... I my C# code i am checking for updates to my email repository, and when I dedect a new email I want to fire the $.growlUI jquery function. I though if I attached it to a div or button element i could call in indirectly.
Dave
for example here you can call javascript from a code behind file http://www.devcurry.com/2009/01/execute-javascript-function-from-aspnet.html
Dave
That link isn't really showing how to call javascript from C#, that's bad terminology on the author's part. What that is doing is injecting javascript into an HTML file. This is a dubious approach if you ask me. Better design: Load the basic HTML file, make jQuery.ajax() calls back to the server to find out if you've got any new emails and fire your growlUI method if the response says there is.
pdr
Ok... thanks for taking the time to post, I appriciate your help
Dave