I recently learned several minor issues related to ASP2.0 (non-innovative articles)

Source: Internet
Author: User
I haven't written any technical logs for a long time, mainly because I haven't studied much recently. However, I was just engaged in asp 2.0 website development. Some simple problems were encountered during the process. Record the summary.

(1) ASP2.0 calls the client script: In PageLoad event processing, add the following code: // after loading all the pages, execute the script ~
If (! This. IsClientScriptBlockRegistered (key ))
{
This. RegisterStartupScript (key, string. Format ("<script language = \" javascript \ "> SwitchPanel ({0}); </script>", sel ));
}

The RegisterStartupScript method calls the script after the page is fully loaded. If it is RegisterClientScriptBlock, it will be called before the page is loaded. Therefore, the script function needs to use the page content here. Therefore, it must be called after the page is loaded.

(2) some basic concepts are basic javascript content.

The following shows how to print the content of a div by outputting its html content to a new window and then printing it.
// Print the page content
Function printPage (div_id)
{
Var newWin = window. open ('printpage ','','');
Var titleHTML = document. getElementById (div_id). innerHTML;
NewWin.doc ument. write (titleHTML );
NewWin.doc ument. location. reload ();
NewWin. print ();
NewWin. close ();
}

In commit Crip, the syntax is very similar to c. The difference is that when a function does not need to be defined, the return value and parameter type do not need to be declared. The string definition can be either single quotation marks or double quotation marks, the primary basis can be used to distinguish the quotation marks in a string from each other. The definition of variables and other places can be seen that the java Script is relatively random and free. This feature is somewhat similar to vba in office software.

You can put a GridView in a div section, and then print only the GridView without including other content on the page.

(3) display the date in the BoundField of the GridView, instead of the default DateTime type (yyyy-MM-dd HH: mm: ss ). String [] fields =; // column name
// Add columns for the GridView
For (int I = 0; I <fields. Length; I ++)
{
BoundField bf = new BoundField ();
Obj = this. GetLocalResourceObject (fields [I]);
Bf. HeaderText = (obj = null )? (Fields [I] + "?? "): Obj. ToString ();
Bf. DataField = fields [I]; // The time, minute, and second column of the date type is not displayed.
If (fields [I]. EndsWith ("Date "))
{
Bf. HtmlEncode = false; // required!
Bf. DataFormatString = "{0: yyyy-MM-dd }";
}
This. GridView1.Columns. Add (bf );
}

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.