Home All Groups Group Topic Archive Search About

Javascript call in Sub Procedure

Author
26 Dec 2006 7:28 PM
mianiro
Hi everyone

I need a little bit of help ... I need to call a javascript function
inside of a .net sub procedure.  Here is my code:

  ClientScript.RegisterClientScriptBlock(Me.GetType(), "", "<script
language='JavaScript'> function OpenChild() " & _
        "{" & _
        "var ParmA = retvalA.value;" & _
        "var ParmB = retvalB.value;" & _
        "var ParmC = retvalC.value;" & _
        "var MyArgs = new Array(ParmA, ParmB, ParmC);" & _
        "var WinSettings =
""center:yes;resizable:no;dialogHeight:300px""" & _
        "var MyArgs = window.showModalDialog(" & _
        """CompanyInfo.aspx"", MyArgs, WinSettings);" & _
        "if (MyArgs == null)" & _
        "{" & _
        "}" & _
        "else" & _
        "{" & _
        "retvalA.value=MyArgs[0].toString();" & _
        "retvalB.value=MyArgs[1].toString();" & _
        "}" & _
        "} </script>")

Am I going about this the right way? Nothing seems to happen when I hit
this code in the debugger. Is there another way to call javascript from
a sub procedure?

Author
26 Dec 2006 9:45 PM
Scott M.
What your code does is send this JavaScript down to the client machine so
that it will be executed on the client-side.  Since it is client-side code,
you can't step through it with the server-side debugger.


Show quote
"mianiro" <mian***@gmail.com> wrote in message
news:1167161312.807346.212840@a3g2000cwd.googlegroups.com...
> Hi everyone
>
> I need a little bit of help ... I need to call a javascript function
> inside of a .net sub procedure.  Here is my code:
>
>  ClientScript.RegisterClientScriptBlock(Me.GetType(), "", "<script
> language='JavaScript'> function OpenChild() " & _
>        "{" & _
>        "var ParmA = retvalA.value;" & _
>        "var ParmB = retvalB.value;" & _
>        "var ParmC = retvalC.value;" & _
>        "var MyArgs = new Array(ParmA, ParmB, ParmC);" & _
>        "var WinSettings =
> ""center:yes;resizable:no;dialogHeight:300px""" & _
>        "var MyArgs = window.showModalDialog(" & _
>        """CompanyInfo.aspx"", MyArgs, WinSettings);" & _
>        "if (MyArgs == null)" & _
>        "{" & _
>        "}" & _
>        "else" & _
>        "{" & _
>        "retvalA.value=MyArgs[0].toString();" & _
>        "retvalB.value=MyArgs[1].toString();" & _
>        "}" & _
>        "} </script>")
>
> Am I going about this the right way? Nothing seems to happen when I hit
> this code in the debugger. Is there another way to call javascript from
> a sub procedure?
>
Author
27 Dec 2006 11:30 PM
Alien2_51
This script just defines the function, I think what you need to do is call
the function.. Declare the function in an include file or inline in the page
and then use something like this to call it...

ClientScript.RegisterClientScriptBlock(Me.GetType(), "", "<script
language='JavaScript'>OpenChild(); </script>")



Show quote
"mianiro" wrote:

> Hi everyone
>
> I need a little bit of help ... I need to call a javascript function
> inside of a .net sub procedure.  Here is my code:
>
>   ClientScript.RegisterClientScriptBlock(Me.GetType(), "", "<script
> language='JavaScript'> function OpenChild() " & _
>         "{" & _
>         "var ParmA = retvalA.value;" & _
>         "var ParmB = retvalB.value;" & _
>         "var ParmC = retvalC.value;" & _
>         "var MyArgs = new Array(ParmA, ParmB, ParmC);" & _
>         "var WinSettings =
> ""center:yes;resizable:no;dialogHeight:300px""" & _
>         "var MyArgs = window.showModalDialog(" & _
>         """CompanyInfo.aspx"", MyArgs, WinSettings);" & _
>         "if (MyArgs == null)" & _
>         "{" & _
>         "}" & _
>         "else" & _
>         "{" & _
>         "retvalA.value=MyArgs[0].toString();" & _
>         "retvalB.value=MyArgs[1].toString();" & _
>         "}" & _
>         "} </script>")
>
> Am I going about this the right way? Nothing seems to happen when I hit
> this code in the debugger. Is there another way to call javascript from
> a sub procedure?
>
>
Author
28 Dec 2006 6:40 PM
mianiro
Yes .. tried that, but no results. I wish i could step through the
javascript. I dont know if it is my js code or the way i'm calling it.
I think I'm going to try a workaround ...

Thanks for the helpthough

On Dec 27, 6:30 pm, Alien2_51 <MSDNNospam...@nospam.nospam> wrote:
Show quote
> This script just defines the function, I think what you need to do is call
> the function.. Declare the function in an include file or inline in the page
> and then use something like this to call it...
>
> ClientScript.RegisterClientScriptBlock(Me.GetType(), "", "<script
> language='JavaScript'>OpenChild(); </script>")
>
>
>
> "mianiro" wrote:
> > Hi everyone
>
> > I need a little bit of help ... I need to call a javascript function
> > inside of a .net sub procedure.  Here is my code:
>
> >   ClientScript.RegisterClientScriptBlock(Me.GetType(), "", "<script
> > language='JavaScript'> function OpenChild() " & _
> >         "{" & _
> >         "var ParmA = retvalA.value;" & _
> >         "var ParmB = retvalB.value;" & _
> >         "var ParmC = retvalC.value;" & _
> >         "var MyArgs = new Array(ParmA, ParmB, ParmC);" & _
> >         "var WinSettings =
> > ""center:yes;resizable:no;dialogHeight:300px""" & _
> >         "var MyArgs = window.showModalDialog(" & _
> >         """CompanyInfo.aspx"", MyArgs, WinSettings);" & _
> >         "if (MyArgs == null)" & _
> >         "{" & _
> >         "}" & _
> >         "else" & _
> >         "{" & _
> >         "retvalA.value=MyArgs[0].toString();" & _
> >         "retvalB.value=MyArgs[1].toString();" & _
> >         "}" & _
> >         "} </script>")
>
> > Am I going about this the right way? Nothing seems to happen when I hit
> > this code in the debugger. Is there another way to call javascript from
> > a sub procedure?- Hide quoted text -- Show quoted text -
Author
28 Dec 2006 6:50 PM
Alien2_51
Try to view the source in the page after it's rendered you should see the
call to your function inline in the code... If it's there try putting an
alert in the function so you know it's firing, if it's not try hard coding it
in the page. Also if it's not there you may want to check your ispostback
logic and make sure the call to RegisterClientScriptBlock is actually
executing..  HTH

Show quote
"mianiro" wrote:

> Yes .. tried that, but no results. I wish i could step through the
> javascript. I dont know if it is my js code or the way i'm calling it.
> I think I'm going to try a workaround ...
>
> Thanks for the helpthough
>
> On Dec 27, 6:30 pm, Alien2_51 <MSDNNospam...@nospam.nospam> wrote:
> > This script just defines the function, I think what you need to do is call
> > the function.. Declare the function in an include file or inline in the page
> > and then use something like this to call it...
> >
> > ClientScript.RegisterClientScriptBlock(Me.GetType(), "", "<script
> > language='JavaScript'>OpenChild(); </script>")
> >
> >
> >
> > "mianiro" wrote:
> > > Hi everyone
> >
> > > I need a little bit of help ... I need to call a javascript function
> > > inside of a .net sub procedure.  Here is my code:
> >
> > >   ClientScript.RegisterClientScriptBlock(Me.GetType(), "", "<script
> > > language='JavaScript'> function OpenChild() " & _
> > >         "{" & _
> > >         "var ParmA = retvalA.value;" & _
> > >         "var ParmB = retvalB.value;" & _
> > >         "var ParmC = retvalC.value;" & _
> > >         "var MyArgs = new Array(ParmA, ParmB, ParmC);" & _
> > >         "var WinSettings =
> > > ""center:yes;resizable:no;dialogHeight:300px""" & _
> > >         "var MyArgs = window.showModalDialog(" & _
> > >         """CompanyInfo.aspx"", MyArgs, WinSettings);" & _
> > >         "if (MyArgs == null)" & _
> > >         "{" & _
> > >         "}" & _
> > >         "else" & _
> > >         "{" & _
> > >         "retvalA.value=MyArgs[0].toString();" & _
> > >         "retvalB.value=MyArgs[1].toString();" & _
> > >         "}" & _
> > >         "} </script>")
> >
> > > Am I going about this the right way? Nothing seems to happen when I hit
> > > this code in the debugger. Is there another way to call javascript from
> > > a sub procedure?- Hide quoted text -- Show quoted text -
>
>

AddThis Social Bookmark Button