We have a javascript function we'd like to call from within a C# method in 
our code-behind file.  The way it has worked historically is we'd call the 
method from a hyperlink, like this:
<a href='javascript:MyMethod(Param1, Param2)' runat="server" 
ID="MyLink">click here</a>
...what I'd like to do now is somehow call "MyMethod" from the code-behind 
file.  I've tried something like this but it doesn't do anything, as best I 
can tell.
void JavaScriptTest()
{
    Response.Write("<script language='javascript'>");
    Response.Write("MyMethod(Param1, Param2);");
    Response.Write("<"+"/script>");
}
If I replace the MyMethod line above with something like a vanilla 
window.alert(), it does work, so I figure I must be close to an answer? 
-- 
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Steve Hershoff" <babb...@nowhere.com> wrote in message 
news:%23mWez%23BDIH...@TK2MSFTNGP06.phx.gbl...
<body onload="JavaScrip: MyMethod(Param1, Param2);">
You need to guarantee that all you controls are available if you function 
using any of your controls's IDs.  It all depends on what you are doing.
Not sure if onload executes after Body loads or not.
"Steve Hershoff" <babb...@nowhere.com> wrote in message 
news:%23mWez%23BDIH...@TK2MSFTNGP06.phx.gbl...
Response.Write("MyMethod(" +Param1 + "," + Param2 + ");");
See the picture?
Peter
-- 
Recursion: see Recursion
site:  http://www.eggheadcafe.com
unBlog:  http://petesbloggerama.blogspot.com
BlogMetaFinder:    http://www.blogmetafinder.com
"Steve Hershoff" wrote:
> Hi everyone,
> 
> We have a javascript function we'd like to call from within a C# method in 
> our code-behind file.  The way it has worked historically is we'd call the 
> method from a hyperlink, like this:
> 
> <a href='javascript:MyMethod(Param1, Param2)' runat="server" 
> ID="MyLink">click here</a>
> 
> ....what I'd like to do now is somehow call "MyMethod" from the code-behind 
As for the parameters being passed in literally, we actually generate the 
method call and appropriate params as a big string, using another method, so 
that should be ok, but your point is well taken.  Thanks!
"Peter Bromberg [C# MVP]" <pbro...@yahoo.yohohhoandabottleofrum.com> wrote 
in message news:AA4A62AD-0A56-40AD...@microsoft.com...