Home All Groups Group Topic Archive Search About

how do you execute javascript after script is regsistered?

Author
31 Jan 2006 3:50 PM
simon
hello,
what code would i use to kick off a javascript script after i had
registered it?

    If (Not Page.IsClientScriptBlockRegistered("jsScript")) Then
         Page.RegisterClientScriptBlock("jsScript", strScript)
    End If

looking to kick off a script from inside a codebehind, but
conditionally not on an onClick event.

is there a way to do this? 
have also played around with
IsStartupScriptRegistered/RegisterStartupScript
but still not sure of how to call that script from one of my functions
in my codebehind

any help would be apprecaited!  thanks

Author
31 Jan 2006 4:01 PM
Cor Ligthert [MVP]
Simon,

Please do not start new threads if you did not got answers in the other one.

The sample is there,

Cor
Author
31 Jan 2006 5:08 PM
simon
hello, sorry for the bad thread etiquette.  thought that my question
would get passed over since there were replies.  thanks for the link,
i'm going to check it out now...

Show quoteHide quote
>Simon,
>
>Please do not start new threads if you did not got answers in the other one.
>
>The sample is there,
>
>Cor
>
Author
31 Jan 2006 5:48 PM
Bruce Barker
you need to look at how asp.net  works:

1) server build page html
2) server sends page html to browser
3) browser parses and loads html

your asp.net code runs in step 1
your javascript runs in step 3

with this model, obviously server code can not call client code. there are a
couple a ways to control when the browser runs the client script. the script
can be tied to the browser onload event, a click event, or inline (processed
during page parse). RegisterStartupScript, renders a  script block just
before the closing form tag, so it a handly plce to inline script.

-- bruce (sqlwork.com)


Show quoteHide quote
"simon" <m*@here.com> wrote in message
news:dd1vt1l4h21lseqddd6dgu2qcs7tbk3psb@4ax.com...
> hello,
> what code would i use to kick off a javascript script after i had
> registered it?
>
>    If (Not Page.IsClientScriptBlockRegistered("jsScript")) Then
>         Page.RegisterClientScriptBlock("jsScript", strScript)
>    End If
>
> looking to kick off a script from inside a codebehind, but
> conditionally not on an onClick event.
>
> is there a way to do this?
> have also played around with
> IsStartupScriptRegistered/RegisterStartupScript
> but still not sure of how to call that script from one of my functions
> in my codebehind
>
> any help would be apprecaited!  thanks
>
Author
31 Jan 2006 6:17 PM
simon
thanks bruce.  i'm getting the clearer picture of client vs server
processing.
regarding inline, that is theoretically what i'm trying to do here
if a condition arrises in the parsing, call a javascript function;
maybe i need to make a little popup window instead of an alert and
call that.  once they click Ok send them to the page i originally
intended.
maybe i'm missing the understanding of inline processing.  would a vb
fucntion call (based on an event) be considered inline processing?

Show quoteHide quote
>you need to look at how asp.net  works:
>
>1) server build page html
>2) server sends page html to browser
>3) browser parses and loads html
>
>your asp.net code runs in step 1
>your javascript runs in step 3
>
>with this model, obviously server code can not call client code. there are a
>couple a ways to control when the browser runs the client script. the script
>can be tied to the browser onload event, a click event, or inline (processed
>during page parse). RegisterStartupScript, renders a  script block just
>before the closing form tag, so it a handly plce to inline script.
>
>-- bruce (sqlwork.com)
>
>
>"simon" <m*@here.com> wrote in message
>news:dd1vt1l4h21lseqddd6dgu2qcs7tbk3psb@4ax.com...
>> hello,
>> what code would i use to kick off a javascript script after i had
>> registered it?
>>
>>    If (Not Page.IsClientScriptBlockRegistered("jsScript")) Then
>>         Page.RegisterClientScriptBlock("jsScript", strScript)
>>    End If
>>
>> looking to kick off a script from inside a codebehind, but
>> conditionally not on an onClick event.
>>
>> is there a way to do this?
>> have also played around with
>> IsStartupScriptRegistered/RegisterStartupScript
>> but still not sure of how to call that script from one of my functions
>> in my codebehind
>>
>> any help would be apprecaited!  thanks
>>
>
Author
1 Feb 2006 10:43 PM
Bruce Barker
no.


<html>
<body>
    <script>

        // inline javascript - executed during page parse by browser

        document.write("<input type=button onclick='btnClick()'>");

        // javascript function executed by user event

        function btnClick()
        {
            alert("clicked button");
        }
    </script>
</body>
</htm>


-- bruce (sqlwork.com)



Show quoteHide quote
"simon" <m*@here.com> wrote in message
news:g8avt15c2foebvfejlelkeav5dmhirdcpo@4ax.com...
> thanks bruce.  i'm getting the clearer picture of client vs server
> processing.
> regarding inline, that is theoretically what i'm trying to do here
> if a condition arrises in the parsing, call a javascript function;
> maybe i need to make a little popup window instead of an alert and
> call that.  once they click Ok send them to the page i originally
> intended.
> maybe i'm missing the understanding of inline processing.  would a vb
> fucntion call (based on an event) be considered inline processing?
>
>>you need to look at how asp.net  works:
>>
>>1) server build page html
>>2) server sends page html to browser
>>3) browser parses and loads html
>>
>>your asp.net code runs in step 1
>>your javascript runs in step 3
>>
>>with this model, obviously server code can not call client code. there are
>>a
>>couple a ways to control when the browser runs the client script. the
>>script
>>can be tied to the browser onload event, a click event, or inline
>>(processed
>>during page parse). RegisterStartupScript, renders a  script block just
>>before the closing form tag, so it a handly plce to inline script.
>>
>>-- bruce (sqlwork.com)
>>
>>
>>"simon" <m*@here.com> wrote in message
>>news:dd1vt1l4h21lseqddd6dgu2qcs7tbk3psb@4ax.com...
>>> hello,
>>> what code would i use to kick off a javascript script after i had
>>> registered it?
>>>
>>>    If (Not Page.IsClientScriptBlockRegistered("jsScript")) Then
>>>         Page.RegisterClientScriptBlock("jsScript", strScript)
>>>    End If
>>>
>>> looking to kick off a script from inside a codebehind, but
>>> conditionally not on an onClick event.
>>>
>>> is there a way to do this?
>>> have also played around with
>>> IsStartupScriptRegistered/RegisterStartupScript
>>> but still not sure of how to call that script from one of my functions
>>> in my codebehind
>>>
>>> any help would be apprecaited!  thanks
>>>
>>
>
Author
2 Feb 2006 5:25 AM
simon
thanks for clarifying

Show quoteHide quote
>no.
>
>
><html>
><body>
>    <script>
>
>        // inline javascript - executed during page parse by browser
>
>        document.write("<input type=button onclick='btnClick()'>");
>
>        // javascript function executed by user event
>
>        function btnClick()
>        {
>            alert("clicked button");
>        }
>    </script>
></body>
></htm>
>
>
>-- bruce (sqlwork.com)
>
>
>
>"simon" <m*@here.com> wrote in message
>news:g8avt15c2foebvfejlelkeav5dmhirdcpo@4ax.com...
>> thanks bruce.  i'm getting the clearer picture of client vs server
>> processing.
>> regarding inline, that is theoretically what i'm trying to do here
>> if a condition arrises in the parsing, call a javascript function;
>> maybe i need to make a little popup window instead of an alert and
>> call that.  once they click Ok send them to the page i originally
>> intended.
>> maybe i'm missing the understanding of inline processing.  would a vb
>> fucntion call (based on an event) be considered inline processing?
>>
>>>you need to look at how asp.net  works:
>>>
>>>1) server build page html
>>>2) server sends page html to browser
>>>3) browser parses and loads html
>>>
>>>your asp.net code runs in step 1
>>>your javascript runs in step 3
>>>
>>>with this model, obviously server code can not call client code. there are
>>>a
>>>couple a ways to control when the browser runs the client script. the
>>>script
>>>can be tied to the browser onload event, a click event, or inline
>>>(processed
>>>during page parse). RegisterStartupScript, renders a  script block just
>>>before the closing form tag, so it a handly plce to inline script.
>>>
>>>-- bruce (sqlwork.com)
>>>
>>>
>>>"simon" <m*@here.com> wrote in message
>>>news:dd1vt1l4h21lseqddd6dgu2qcs7tbk3psb@4ax.com...
>>>> hello,
>>>> what code would i use to kick off a javascript script after i had
>>>> registered it?
>>>>
>>>>    If (Not Page.IsClientScriptBlockRegistered("jsScript")) Then
>>>>         Page.RegisterClientScriptBlock("jsScript", strScript)
>>>>    End If
>>>>
>>>> looking to kick off a script from inside a codebehind, but
>>>> conditionally not on an onClick event.
>>>>
>>>> is there a way to do this?
>>>> have also played around with
>>>> IsStartupScriptRegistered/RegisterStartupScript
>>>> but still not sure of how to call that script from one of my functions
>>>> in my codebehind
>>>>
>>>> any help would be apprecaited!  thanks
>>>>
>>>
>>
>