asp.netÊý¾Ý°ó¶¨Ö®EvalºÍBind ºÍµÈÇø±ð
EvalÊÇasp.net1.1Öг£
Óõİó¶¨Óï·¨£¬ËüÊÇ“µ¥Ïò”µÄ£¬¼´°ó¶¨Ê±°ÑÊý¾ÝÔ´ÉÏÏàÓ¦µÄÖµ¸³µ½¸Ã¿Ø¼þÉÏ£¬EvalµÄÈÎÎñ¾ÍÍê³ÉÁË
¶øBindËùνµÄ“Ë«Ïò”¾ÍÊÇ£ºÔÚ°ó¶¨Ê±£¬°Ñ
Êý¾ÝÔ´ÉÏÏàÓ¦µÄÖµ¸³µ½¸Ã¿Ø¼þÉÏ£¬²¢ÇÒ£¬ÔÚÌύʱ£¬×Ô¶¯ÌáÈ¡Óû§ÔڸÿؼþÉÏÊäÈëµÄÖµ¡£
Code
<
EditItemTemplate
>
<
asp:Label
ID
="CityIDLabel1"
runat
="server"
Text
='<%#
Eval("CityID") %
>
'>
</
asp:Label
>
<
asp:TextBox
ID
="CityTextBox"
runat
="server"
Text
='<%#
Bind("City") %
>
'>
</
asp:TextBox
>
</
EditItemTemplate
>
ÓÖÀý£º
Eval£º°ó¶¨µÄÊÇÖ»¶ÁÊý¾ÝµÄÏÔ
ʾ£»Bind£º¿ÉÒÔ°ó¶¨Ö»¶ÁÊý¾ÝÒ²¿ÉÒ԰󶨸üÐÂÊý¾Ý£¬Bind·½·¨»¹°Ñ×ֶκͿؼþµÄ°ó¶¨ÊôÐÔÁªÏµÆðÀ´£¬Ê¹µÃÊý¾Ý¿Ø¼þ£¨±ÈÈçGridViewµÈ£©µÄ
Update¡¢InsertºÍDeleteµÈ·½·¨¿ÉÒÔʹÓÃÕâÖÖÁªÏµÀ´×÷³öÏàÓ¦µÄ´¦Àí¡£
Eval ºÍ Bind°ó¶¨µÄÊý¾ÝÔÚ<%#
%> ÏÔʾ£¬ Èô¶ÔÒªÏÔʾµÄÊý¾Ý×÷Ð޸ĻòÕß²Ù×÷Ò²ÔÚ<%# %> ÖУ¬ÀýÈ磺
1£¬ ¶ÔÏÔʾµÄ×Ö·û´®×÷×Ö·ûÏÔʾ:
<%
# (
Eval
(
"
Address
"
)).ToString().SubString(
0
,
10
)
%>
ÏÔ
ʾ10λÊýµÄµØÖ·¡£
2£¬ ¶ÔÏÔʾµÄÐÅÏ¢×÷ÅжÏ:
<%
# (
Eval
(
"
if_delete
"
)).ToString
==
"
yes
"
?
"
ÒÑɾ
³ý
"
:
"
δɾ³ý
"
%>
--------------------------------------------------------------------------------------------------------------------------------
<% %> An embedded code block is server code that executes during
the page's render phase. The code in the block can execute programming
statements and call functions in the current page class.
http://msdn2.microsoft.com/en-gb/library/ms178135(vs.80).aspx
<%=
%> most useful for displaying single pieces of information.
http://msdn2.microsof
Ïà¹ØÎĵµ£º
1.
±£Ö¤xp»·¾³ÒѾ°²×°ÓÐ.net framework 3.5 sp1¡¢asp.net mvc 1.0»ò2.0
2.
ÓÉÓÚiis5.1Ö»ÓÐÒ»¸öĬÈÏÍøÕ¾£¬Òò´ËÏȽ«Ä¬ÈÏÍøÕ¾µÄÆäËûÎļþ·Åµ½ÆäËûλÖ㬽«ÏîÄ¿Îļþ¿½±´µ½Ä¬ÈÏÍøÕ¾ËùÔÚĿ¼£¨Ò»°ãÊÇ£ºC:\Inetpub\wwwroot£©£¬ÐÞ¸ÄÏàÓ¦µÄÁ¬½Ó×Ö·û´®¡£
3. ......
1¡¢ÔÚcompilation Ï£¬ÇëÉèÖÃdebug=false £¬ÈçÏ£º
default Language="c#" debug="false">
2¡¢ÇëʹÓÃServer.Transfer´úÌæResponse.Redirect¡£
3¡¢Ê¹ÓÃValidator¿Ø¼þ£¬ÇëÒª¾³£¼ì²éPage.IsValid¡£
4¡¢ÇëʹÓÃforeachÑ»·£¬¶ø²»ÊÇΪ×Ö·û´®µü´úÑ»·¡£
5¡¢ÇëʹÓÿͻ§¶ËÑéÖ¤·½Ê½(²»ÒªÃ¿´Î¶¼ÔÚ·þÎñ¶ËÑéÖ¤)¡£
6¡¢ÎªÁ˱ÜÃâÖ ......
ʹÓÃvs 2005,·¢ÏÖ¸ù±¾´ò²»¿ªÀÏʦ·¢¹ýÀ´µÄÔ´´úÂëPortal_Article.csprojÎļþ,ÉÏÍø²éÁËÒ»ÏÂ,ºÃ¶àÈ˶¼ËµÊÇÊÇÒòΪûÓиøvs
2005´ò²¹¶¡.ÎÒµÄн¨ÏîÄ¿Àï¸ù±¾Ã»ÓÐASP.NET WEBÓ¦ÓóÌÐò,¾¹ýÒ»¸öÏÂÎçµÄŬÁ¦,ÖÕÓÚ×ܽá³öÁË,½â¾öÎÊÌâµÄ·½·¨.
1.ÏÈ´Ó΢ÈíÍøÕ¾ÏÂÔØ²¹¶¡.
ÏÂÔØµØÖ·1Ϊ£ºhttp://download.microso ......
´ÓÊý¾Ý¿âÈ¡³öÊý¾ÝÈ»ºó¶¯Ì¬µÄÉú³Éhtml¾²Ì¬Ò³Ãæ¡£ÕâÖÖ¼¼ÊõÌØ±ðÊÇÔÚÓµÓдóÁ¿Ò³ÃæµÄÍøÕ¾ÖÐÏÔµÄÌØ±ðµÄÖØÒª
¾ßÌå²½ÖèÎÒÏêϸµÄдһÏÂ
1.½¨Á¢¾²Ì¬Ä£°åÒ³Ãæ¡£Ò²¾ÍÊǽ¨Á¢ÆðÄ£°åÒ³ÃæµÄ¼Ü¹¹
2.È»ºó´Óºǫ́Êý¾Ý¿âÖÐÌáÈ¡ÄÚÈÝ£¬½øÐÐÌæ»»
3.°ÑÌæ»»ºóµÄ×Ö·û´®Ð´ÈëÖÐ
ÎÒÒ²°´ÕÕÉÏÃæµÄ˳Ðò×öһϰÉ
Ê×ÏȽ¨Á¢Ò»¸öÄ£°åHtmlÈ¡ÃûModelHtml.htm. ......
public static bool GetClientWeb()
{
bool result = false;
string clientType = string.Concat(HttpContext.Current.Request.UserAgent);
if (clientType.ToLower().Contains("mozilla") || clientType.ToLo ......