Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

½ÒÃØASP.NET 2.0µÄEval·½·¨

À´Ô´£ºhttp://www.pccode.net/info/2010/01/25/20100125-1220.html
ʵ¼ÊÉÏEval·½·¨ÊÇTemplateControlµÄ£¬¶øSystem.Web.UI.PageºÍSystem.Web.UI.UserControl¶¼¼Ì³ÐÓÚTemplateControl£¬ËùÒÔÎÒÃÇ¿ÉÒÔÔÚPageºÍUserControlÉÏÖ±½Óµ÷Óøö·½·¨¡£  
   
     Page.Eval·½·¨¿ÉÒÔ°ïÖúÎÒÃǸüºÃµÄ׫дÊý¾Ý°ó¶¨±í´ïʽ£¬ÔÚASP.NET   1.xʱ´ú£¬Êý¾Ý°ó¶¨±í´ïʽµÄÒ»°ãÐÎʽÊÇ£º
 <%# DataBinder.Eval(Container,“DataItem.Name”)   %>  
     ¶øÔÚASP.NET   2.0ÖУ¬Í¬ÑùµÄ´úÂ룬ÎÒÃÇ¿ÉÒÔÕâÑùд£º
 
<%# Eval(“Name”)%>
 
     ASP.NET   2.0ÊÇÔõôʵÏÖµÄÄØ£¿ÎÒÃÇÏÈ´ÓEval·½·¨À´Ñо¿£¬Í¨¹ý·´Éä.NET  fromwork   2.0Àà¿âµÄÔ´´úÂ룬ÎÒÃÇ¿ÉÒÔ¿´µ½Õâ¸ö·½·¨ÊÇÕâÑùʵÏֵģº
  
protected   internal   object   Eval(string   expression)  
{  
     this.CheckPageExists();  
     return   DataBinder.Eval(this.Page.GetDataItem(),   expression);  
}  
     µÚÒ»ÐÐÎÒÃDz»±Ø¹Ü£¬ÕâÊǼì²éµ÷ÓõÄʱºòÓÐûÓÐPage¶ÔÏóµÄ£¬Èç¹ûûÓÐÔò»áÅ׳öÒ»¸öÒì³£¡£   ¹Ø¼üÊǵڶþÐУº  
 
 return   DataBinder.Eval(this.Page.GetDataItem(),   expression);  
 
     Page.GetDataItem()Ò²ÊÇ2.0ÖÐÐÂÔöµÄÒ»¸ö·½·¨£¬ÓÃ;ÊÇÕýÊÇÈ¡´úASP.NET   1.xÖеÄContainer.DataItem¡£  
     ¿´À´²»ÃþÇå³þGetDataItem()·½·¨£¬ÎÒÃÇÒ²ºÜÄÑÃ÷°×EvalµÄÔ­Àí¡£GetDataItemµÄʵÏÖÒ²ºÜ¼òµ¥£º
 
public   object   GetDataItem()  
{  
     if   ((this._dataBindingContext ==  null) || (this._dataBindingContext.Count == 0))  
     {  
       &nbs


Ïà¹ØÎĵµ£º

Asp.Net ButtonµÄUseSubmitBehaviorÊôÐÔ

ÔÚijҳÃæÉÏÓÐÈçÏÂÐÅÏ¢£¬
Html£¬
<asp:Button ID="btn" runat="server" Text="Click me" OnClick="ButtonClicked" />
<script language="javascript">
function javascriptMethod() {
alert(1);
}

</script>
C#£¬
protected void ButtonClic ......

asp.net½áºÏhtml£¬javascriptʵÏÖÎÞˢпçÓòÊý¾ÝÌá½»

ÐèÇó£º
AÓòÓÐÒ³Ãæa.html£¬ÆäÖÐÓÐiframe°üº¬BÓòµÄÒ³Ãæb.html£¬ÏÖÔÚҪͨ¹ýa.htmlÉϵÄÒ»¸ö°´Å¥£¬À´°Ña.htmlÒ³ÃæÉÏÒ»¸öÎı¾¿òµÄÖµ´«µÝµ½b.htmlÒ³ÃæµÄÎı¾¿ò¡£
×¢£ºÕâÀïb.htmlÊÇhtmlÍøÒ³£¬²»ÄܽÓÊÕÆäËûÍøÕ¾post¹ýÀ´µÄÖµ£¬ËùÒÔ²»ÄÜÓÃÖ±½ÓpostµÄ·½·¨À´´«Öµ£¬µ«ÊÇ£¬Èç¹û½ÓÊÕÒ³ÃæÊÇb.aspx»òÕßb.asp ÄØ£¬ÄDz»ÊÇ¿ÉÒÔÖ±½ÓpostÁËô£¿´ð ......

ASP.NET¶¯Ì¬¼ÓÔØÓû§¿Ø¼þµÄʵÏÖ·½·¨

µÚÒ»²½£ºÀýÈçÓû§¿Ø¼þ·ÅÔÚMyList.Ascx£¬È»ºóÆäControlÖ¸ÁîÊÇ£º
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ViewComment.ascx.cs" Inherits="Control_ViewComment"%>
ÕâʱºòÒѾ­ÓÐÁËInherits£¬×Ô´øÁËClassName¾ÍÊÇÆäÃû³Æ£¬Èç¹ûûÓУ¬Ôò±ØÐë´´½¨ClassNameÊôÐÔ¡£
¼ÙÉèÆäÓй«¹²ÊôÐÔID¡£
µÚ¶þ²½£ ......

½Å±¾(JS)¹Ø±Õ´°Ì壨ASP.NET£©

¹Ø±Õ´°Ìå 
  1.
      this.btnClose.Attributes.Add("onclick",  "window.close();return false;");
  2.¹Ø±Õ±¾´°Ìå¼äÌøתµ½ÁíÒ»¸öÒ³Ãæ
      this.HyperLink1.NavigateUrl = "javascript:onclick=window.opener.location.assign
        ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ