Thanks Peter (and others). I'd be interested in your input on some other
ways of doing this?
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]" <(E-Mail Removed)> wrote
in message news:AA4A62AD-0A56-40AD-83D7-(E-Mail Removed)...
> Steve,
> you could certainly do it this way (there are others, to be sure). But I
> think the real problem you have is that you are passing literal string
> values
> of "Param1, Param2" instead of the actual values which would need to be
> concatenated:
>
> 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
>> 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?
>>
>>
>>