Emit client script blocks in page

Source: Internet
Author: User
Tags closing tag comment tag emit html comment
Private Sub SetFocus (ByVal controltofocus as Control)
Dim Scriptfunction as New StringBuilder
Dim Scriptclientid as String
Scriptclientid = Controltofocus.clientid
Scriptfunction.append ("<script language= vbscript>")
Scriptfunction.append ("Form1." & Scriptclientid & ". Focus")
Scriptfunction.append ("</script>")
RegisterStartupScript ("Focus", scriptfunction.tostring ())
End Sub
Description: The String object is immutable. Each time you use one of the methods in the System.String class, you create a new string object in memory, which requires a new space to be allocated for the new object. The system overhead associated with creating a new string object can be expensive when you need to perform repeated modifications to the string. If you want to modify a string without creating a new object, you can use the System.Text.StringBuilder class. For example, when you concatenate many strings together in a loop, using the StringBuilder class can improve performance.
RegisterStartupScript: Allow ASP.net server control to emit client script blocks in Page
Like the RegisterClientScriptBlock method, this method emits the script before the <form of the Page object runat= the closing tag of the server> element. When an object that renders the page is defined when the script block is emitted, you must also include two tags for the <script> element.
By using the key identity script, multiple server control instances can request the script block without sending it to the output stream two times.
Any script block with the same key parameter value is treated as duplicates.
Note Remember to add an HTML comment tag around the script so that the script does not render when the requesting browser does not support the script.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.