RegisterStartupScript

L

Lukman

Hi,
Could you tell me about what is RegisterStartupScript, I try to understand
from MSDN sample, but I still don't understand. Could you give me more
simple sample ? and what is the purpose of RegisterStartupScript.
Thanks,
 
K

Ken Cox [Microsoft MVP]

There's an example in an article that I wrote some time ago:

http://www.ftponline.com/vsm/2002_07/magazine/columns/aspnet/page5.aspx


RegisterArrayDeclaration Inserts an array declaration into the HTML code,
including the <script> tags. Accepts both the array name and a
comma-separated list of values as a string.

RegisterClientScriptBlock Inserts a block of client-side code within the
HTML form. The first parameter is an identifying name for the block as a
string. The second parameter is a string containing the script to be sent to
the client. You must include the <script> tags.

RegisterHiddenField Inserts a hidden input field with the HTML form. The
first parameter is a string that provides the input control's name. The
second parameter, also a string, is the field's initial value. In the
rendered content, this field appears just before ASP.NET's hidden
"__VIEWSTATE" field.

RegisterOnSubmitStatement Inserts an OnSubmit attribute into the page's
<form> tag and the script to be called as its value. The first parameter is
a unique identifier for the script as a string. The second value is the
statement or function called. This creates inline code, so no <script> tags
are allowed.

RegisterStartupScript Inserts a script block just before the closing </form>
tag. The first parameter is a unique identifier for the script as a string.
The second parameter, also a string, is the complete script including the
<script> tags.
 
B

bruce barker

their are a couple Register script methods. basically they control where the
script is genereated, and to help support controls that need javascript,
they are named, so the code is only generated once.

<html>
<body>
<form onsubmit="// RegisterOnSubmitStatement - goes here">
<!-- RegisterArrayDeclaration goes here - before any script -->
<!-- RegisterClientScriptBlock goes here - before any form controls -->

......
......

<!-- RegisterStartupScript goes here, after all form controls -->
</form>
</body>
</html>

-- bruce (sqlwork.com)
 
L

Lukman

Thanks Ken, the article is really helpful. Where can I find others articles
from you ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top