×÷ΪASP.NET¿ª·¢ÈËÔ±±ØÐëÑø³ÉµÄ±à³ÌÏ°¹ß
ÈÃÎÒÃǵijÌÐòдµÃ¸ü¼ÓƽÒ×½üÈË£¬¸ü¼ÓÉú¶¯¶ÔÎÒÃǵıà³ÌÊÇ´óÓÐÒæ´¦µÄ¡£¶ÔÎÒÃǵijÌÐòѧϰҲÄÜÆðµ½Ê°빦±¶µÄ×÷Óᣱà³Ì¹ý³ÌÖÐ×ñÊصIJ»³ÉÎĵıê×¼£¬¶ÔÓÚÎÒÃǺÍËûÈ˵Ľ»Á÷ºÍ×Ô¼ºµÄÔÙѧϰ¶¼ÊÇÓÐÒæÎÞº¦µÄ¡£±Ï¾¹ÓÐʱÎÒÃÇдµÄ³ÌÐò²»ÊÇÖ»¸ø×Ô¼º¿´µÄ£¬Ò²²»ÊÇһʱÐËÆ𣬲»¹ÜÒÔºó¡£ ºÃµÄ±àÂë¿ÉʹԴ´úÂëµÄ¿É¶ÁÐÔÇ¿ÇÒÒâÒåÇå³þ£¬ÓëÆäËûÓïÑÔÔ¼¶¨ÏàÒ»Ö£¬²¢ÇÒ¾¡¿ÉÄÜÖ±¹Û¡£
1.´íÎó£¨ÒÔÍ⣩µÄ´¦Àí
³ÌÐò½¡×³ÐÔ×î»ù±¾ÒªÇó¾ÍÊdzÌÐò´íÎóµÄ´¦ÀíÓ벶׽£¬ÔÚASP.NETÖУ¬´íÎóµÄ´¦ÀíÓкÍÆäËû±à³ÌÓïÑÔÒ»ÑùµÄ»úÖÆ£¬¿ÉÒÔʹÓÃTry…Catch… FinallyµÈ·½Ê½£¬ÕâÒ»µãºÍASPÏà±È¾ßÓнϴóµÄ½ø²½¡£¶øÇÒ£¬Ê¹ÓÃÕâЩ´íÎó´¦Àí·½·¨£¬¿ÉÒÔ´ó´óÌá¸ß³ÌÐòµÄ¿É¶ÁÐԺͳÌÐòµ÷ÊÔËٶȣ¬ÔÚÕ⼸¸öÓÅÊƽáºÏµÄÇé¿öÏ£¬ÎÒÃǸü¼ÓÓ¦¸Ã×¢ÒâÕâÒ»µã¡£
2.×Ö·û´®µÄ´¦Àí
ÍøÒ³Éè¼ÆÖУ¬×Ö·û´®µÄ´¦Àí¼¸ºõÊÇ×î³£¼ûµÄÁË¡£Ê¹ÓÃASP.NETÒÔºó£¬×Ö·û´®µÄ´¦Àí±ÈASPµÄËٶȿ죬¶øÇÒ£¬ÔÚASP.NETÖУ¬×¨ÃÅÔö¼ÓÒ»¸ö×Ö·û´®´¦ÀíÀàStringBulider£¬Ê¹ÓÃÕâ¸öÀà¿ÉÒÔÍê³ÉһЩ³£¼ûµÄ×Ö·û´®²Ù×÷£¬¶ø×îÖ÷ÒªµÄ£¬Ê¹ÓÃStringBuilder¿ÉÒÔ´ó´óÌá¸ß×Ö·û´®´¦ÀíËٶȡ£
ÔÚASP.NETÖУ¬×î³£¼ûµÄ¾ÍÊÇʹÓÓ&”À´Á¬½ÓÁ½¸ö×Ö·û´®£º
ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º
Dim myOutputString As String = "My name is"
Dim myInputString As String = " Alex"
myOutputString = myOutputString & myInputString
Response.Write(myoutputString)
ÏÖÔÚ£¬ÎÒÃÇÀ´¿´¿´StringBuilderµÄʹÓã¬ÔÚʹÓÃStringBuilderµÄʱºò£¬ÎÒÃǶÔ×Ö·û´®¿ÉÒÔ×öһЩ»ù±¾µÄ²Ù×÷£¬±ÈÈçAppend¡¢Replace¡¢Insert¡¢RemoveµÈ£¬ÏÖÔÚÎÒÃÇÀ´¿´¾ßÌå¾ÙÀý¡£
£¨1£©StringBuilderÖÐAppendµÄʹÓÃ
AppendºÍÆäËûÓïÑÔµÄAppendÒ»Ñù£¬¾ÍÊÇÔÚ×Ö·û´®×îºóÔö¼ÓÆäËû×Ö·û¡£
ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º
http://www.CodeHighlighter.com/
-->Dim sb as StringBuilder = New StringBuilder()
sb.append( " ")
sb.Append( dt.Rows(i).Item(k, DataRowVersion.Current).toString())
sb.Append( "")
Dim strOutput as String = sb.ToString()
lblCompany.Text = strOutput
ÔÚÒÔÉϵijÌÐòÖУ¬ÓÃAppend·½·¨ÊµÏÖÁËÒ»¸ö±í¸ñµÄÊä³ö£¬ÐèҪעÒâµÄÒ»µãÊÇ£¬StringBulider±ØÐëÊ×ÏÈʹÓÃToString()·½·¨½«Æäת»¯ÎªStringÀàÐͲſÉÒÔÖ±½ÓÊä³ö¡£ÔÚÒÔÉϵľÙÀýÖУ¬ÎÒÃÇ¿´µ½µÄÈ«²¿ÊÇAppendÒ»¸öÖ±½ÓµÄ×Ö·û´®£¬Æäʵ£¬Õâ¸ö·½·¨ÓÐÒ»¸öºÜ·½±ãµÄ¹¦ÄÜ£¬ÄǾÍÊÇ¿ÉÒÔÖ±½Ó AppendÆäËûÀàÐ͵ıäÁ¿£¬±ÈÈç¿ÉÒÔÖ±½ÓAppemdÒ»¸öIntegerÀàÐ͵
Ïà¹ØÎĵµ£º
ASP.NET Literal¿Ø¼þÓ÷¨_»ªÎª½ðɽÍø
ÔÚÄúÒªÒÔ±à³Ì·½Ê½ÉèÖÃÎı¾¶ø²»Ìí¼Ó¶îÍâµÄ HTML ±ê¼Çʱ£¬¿ÉÒÔÏòÒ³ÃæÌí¼Ó Literal Web ·þÎñÆ÷¿Ø¼þ¡£ÔÚÒªÏòÒ³Ã涯̬Ìí¼ÓÎı¾¶ø²»Ìí¼ÓÈκβ»ÊôÓڸö¯Ì¬Îı¾µÄÔªËØʱ£¬Literal ¿Ø¼þ·Ç³£ÓÐÓá£ÀýÈ磬Äú¿ÉÒÔʹÓà Literal ¿Ø¼þÀ´ÏÔʾ´ÓÎļþ»òÁ÷ÖжÁÈ¡µÄ HTML¡£
×¢Òâ
Èç¹ûÒªÏÔʾ¾²Ì¬Îı¾£¬ ......
Ò»¡¢Ä¿Ç°ÔÚASP.NETÖÐÒ³Ãæ´«Öµ¹²ÓÐÕâô¼¸ÖÖ·½Ê½£º
1¡¢±íµ¥Ìá½»£¬
<form action= "target.aspx" method = "post" name = "form1">
<input name = "param1" value = "1111"/>
<input name = "param2" value = "2222"/>
</form>
....
&nbs ......
ÍøÂç´òÓ¡¸ÅÊö
¡¡¡¡• B/S½á¹¹µ¼ÖÂÁËWebÓ¦ÓóÌÐòÖдòÓ¡µÄÌØÊâÐÔ¡£
¡¡¡¡• ³ÌÐòÔËÐÐÔÚä¯ÀÀÆ÷ÖУ¬´òÓ¡»úÔÚ±¾µØ£¬¶øÎļþÈ·¿ÉÄÜÔÚ·þÎñÆ÷ÉÏ£¬µ¼ÖÂÁË´òÓ¡¿ØÖƲ»ÊǺÜÁé»î¡£
¡¡¡¡• ¸ñʽÈçºÎ¿ØÖƺͶ¨ÖƵȣ¬ÊÇÎÒÃÇ¿ª·¢ÖпÉÄÜ»áÃæ¶ÔµÄÎÊÌâ¡£
¡¡¡¡´òÓ¡ÎĵµµÄÉú³É
¡¡¡¡• 1¡¢¿Í»§¶Ë½Å±¾·½Ê½
¡¡¡¡Ò»°ãÇé¿öÏ£¬Ö÷ÒªÊ ......
£¼input id = " loFile " type = " file " runat = " server " £¾
£¼form method = " post " enctype =" multipart/form-data " runat = " server "£¾
£¼/form £¾
1.»ñµÃÉÏ´«ÎļþµÄÃû³Æ£º£¨¹Ø¼üÊÇPostedFileÀàµÄÓ¦Óã©
ʹÓÃPathÀàÖеÄGetFileName·½·¨£¬¾ßÌåÈçÏ£º
lstrFileName = loFile.PostedFile.FileName
......
ÎÒÃÇÔÚAsp.Net¿ª·¢¹ý³ÌÖУ¬ÓÐʱºòΪÁË¿ª·¢µÄÐèÒª£¬»ò´ïµ½Ò»¶¨µÄЧ¹û£¬ÎÒÃÇ»á²ÅÈ¡¶¯Ì¬¼ÓÔØÓû§¿Ø¼þµÄ·½·¨À´ÊµÏÖ£¬¶¯Ì¬¼ÓÔØÓû§¿Ø¼þ£¬¿ÉÒÔÔÚͬһ¸öÒ³ÃæÀïÃ棬¸ù¾Ý²»Í¬µÄÇé¿öÏÔʾ²»Í¬µÄÄÚÈÝ£¬Ê¹ÎÒÃÇÔÚ¿ª·¢Ê¡Ê±Ê¡Á¦¡£
¡¡ÄÇôÎÒÃÇÔõôʵÏÖ¶¯Ì¬¼ÓÔØÓû§¿Ø¼þÄØ£¬ÆäʱºÜ¼òµ¥£¬ÎÒÃÇÖ»ÒªÔÚÒ³ÃæÀïÒª·Å¿ØµÄ¼þµÄµØ·½·ÅÒ»¸öռλ¿Ø¼þ &l ......