½ÒÃØ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
Ïà¹ØÎĵµ£º
ÕâÀïÊÇ´ÓDatasetÀïµÄÊý¾ÝÉú³ÉÇúÏßͼ.
ÎÒµÄDatasetÊÇ´Ó±íSendrecÀï¶ÁÈ¡µÄÊý¾Ý,·Ö±ðÓÐId,Sendid(¶©µ¥ºÅ),Sendtime(¼Ç¼ʱ¼ä),Sendnum(µ¥Î»Ê±¼ä·¢ËÍÁ¿/ÎÒÕâÀïÊÇÎå·ÖÖÓ)¼¸¸ö×Ö¶Î
¹ý³ÌÈçÏÂ:
public void draw(Page page,DataSet ds,int Tnum){}
ÆäÖÐpageÊÇÓÃÀ´´«µÝÒýÓÃÕâ¸ö¹ý³ÌµÄÒ³Ãæ,ÕâÑùÈÃÒ³ÃæÊÇJPG·½Ê½Ö±½ÓÏò¿Í»§¶ËÊä³öÉú ......
Javascript ÔÚASP.net ĸ°åҳϷÃÎÊ ¿Ø¼þID£º
¶ÔÓÚ html control : Ö±½Ó·ÃÎÊID
document.getElementById("hfRespondID");
¶ÔÓÚ Web control :
document.getElementById("<%= this.hfRespondID.ClientID %>") [×¢Òâ´óСд
]
&nb ......
ÉÏ´Î×öÁ˸öÏîÄ¿£¬Éæ¼°µ½Êý¾Ý¿âµÄ»¹ÔºÍ»Ö¸´£¬µ½ÍøÉÏÕÒÁËһϣ¬ÊÇÀûÓÃSQLDMOʵÏֵģ¬Ö»ÒªÌí¼ÓSQLDMOÒýÓþͺÃÁË£¬È»ºóÀûÓÃϱߵÄÀàµÄ·½·¨¾Í¿ÉÒÔʵÏÖÁË¡£
ÎÒ°ÑÔ×÷ÕßµÄÀàÀ©³äÁËһϣ¬¿ÉÒÔ×Ô¶¯Ê¶±ðweb.configÀï µÄÊý¾Ý¿âÁ¬½Ó×Ö·û´®£¬¿ÉÒÔͨ¹ý±äÁ¿ÉèÖû¹Ô»Ö¸´µÄÐÅÏ¢¡£
ÐèҪעÒâµÄʱ»¹Ô£¬»¹ÔµÄʱºòÎÊÌ ......
¸ø³öÈçÏÂÀý×Ó ÎÒÖ»ÖªµÀÕâÑù×ö¿ÉÒÔµ÷ÓÃÉÏÒ»¸öÒ³Ãæ µÄÖµ»òÕß·½·¨ µ«ÊÇÎÒ²»ÖªµÀÔÀíºÍËüµÄÓÅÂÔ
Çë¸ßÊÖ ¼ÓÒÔÖ¸µã ´ó¼Ò¹²Í¬Ñ§Ï° лл£¡
1.Default.aspx Ò³Ãæ
protected void but1_Click(object sender, EventArgs e)
{
Server.Transfer("Default2.aspx");
......
Asp.netÁ¬½ÓSQL Server2000Êý¾Ý¿âÀý³ÌÏê½â:
<%@ Import Namespace="System.Data" %>
<%@ Import NameSpace="System.Data.SqlClient" %>
<script laguage="VB" runat="server">
sub page_load(sender as Object ......