1. // the dialog box is displayed. Click to go to the specified page.
Response. Write ("<SCRIPT> window. Alert ('This member has not submitted an application. Please submit it again! ') </SCRIPT> ");
Response. Write ("<SCRIPT> window. Location = 'HTTP: // www.51aspx.com/bizpulic/upmeb.aspx' </SCRIPT> ");
2. // pop-up dialog box
Response. Write ("<script language = 'javascript '> alert ('product added successfully! ')
Every time I see such code, I want to kick people. Fortunately, you are not my team.
4. // bind the drop-down list box datalist
System. Data. dataview DV = conn. exec_ex ("select-1 as code, 'select business mode' As content from Dealin Union Select Code, content from Dealin ");
This. dealincode. datasource = DV;
This. dealincode. datatextfield = "content ";
This. dealincode. datavaluefield = "code ";
This. dealincode. databind ();
This. dealincode. Items. findbyvalue (DV [0] ["dealincode"]. tostring (). Selected = true;
Is it better to use the following code in the last line:
Dealincode. selectedvalue = DV [0] ["dealincode"]. tostring ();
5. // display the time in seconds
<% # System. datetime. parse (databinder. eval (container. dataitem, "begtime"). tostring (). to1_datestring () %>
Datetime. tow.datestring () Can you go back to the test in seconds?
If you can't, congratulations, you won't trust such a ghost code any more. If yes, open the windows control panel, find the "Language and Culture" option, and try to modify the short date display format
Come back and execute the code. How is the result? Is it amazing, isn't it strange?
Let's take a look at the language and culture of the thread.
Use the following code to display the time in seconds:
Datetime. tostring ("yyyy-m-d h: M ")
10. // extract dynamic webpage content
Uri uri = new uri ("http://www.51aspx.com /");
Webrequest Req = webrequest. Create (URI );
Webresponse resp = Req. getresponse ();
Stream STR = resp. getresponsestream ();
Streamreader sr = new streamreader (STR, system. Text. encoding. Default );
String T = Sr. readtoend ();
This. response. Write (T. tostring ());
OK. The code looks normal and the execution result is as expected. Everything is perfect ".
However, should stream objects be closed after execution or when exceptions occur?
In addition, why is string. tostring () required ()
What is the significance of such code?
Why use the default encoding for request? What are the consequences under different circumstances?
It's no wonder that most of the so-called C # programmers are so cheap.
11. // get the characters After "."
I. tostring (). Trim (). substring (I. tostring (). Trim (). lastindexof (".") + 1). tolower (). Trim ()
I don't know what you think of this Code.
How many string objects (SPAM objects) are generated and how readable the code is.
Since we need to take the characters after. So we can use TRIM () at will, using tolower () is the right given to you by that requirement document?
Also, what if string. lastindexof (string) is equal to-1?
The following code is more acceptable:
String temp = I. tostring ();
Int dotindex = temp. lastindexof (".");
Return temp. substring (dotindex + 1 );
12. Add dialog box for button
Button1.attributes. Add ("onclick", "Return confirm ('OK? ')");
Button. Attributes. Add ("onclick", "If (confirm ('Are you sure ...? ') {Return true;} else {return false ;}")
If (confirm ('Are you sure ...? ') {Return true;} else {return false ;}
Change
Return confirm ('Are you sure? ')
Is it better?