我定义了一组div,如下所示:
foreach (RideOfferInfo offer in rideOfferRes.GetTransportationOffersResult)
{
//if (offer.AutoServiceAvailable != "no auto-service" )
//{
Session["OfferDivs"] +=
String.Format(@"<div class=""srv-boxes"" id=""srvbox{0}"" OnClick=""OnChooseRide"" runat=""server"">", i) + Environment.NewLine +
String.Format(@"<img class=""srv-boxes-img"" src=""{0}"" />", offer.Image) + Environment.NewLine +
@"<div class=""srv-boxes-details"">" + Environment.NewLine +
String.Format("<div>{0}</div>", offer.Description) + Environment.NewLine +
String.Format(@"<div class=""detaisl-rows""><img src=""passengers.png"" /> {0} PAX</div>", offer.MaxPassengers) + Environment.NewLine +
String.Format(@"<div class=""srv-boxes-details-pricebox detaisl-rows"">{0} {1}</div>", offer.ClientPrice, offer.Currency) + Environment.NewLine +
"</div></div>";
//}
i++;
}
aspx文件调用一个函数,该函数返回当前会话的列表版本。
<div class="cmn1-scroll">
<%=GetOfferDivs() %>
</div>
使用以下签名定义该函数:
protected void OnChooseRide(object sender, EventArgs e)
当我在Chrome DevTools中检查div时,我看到了
<div class="srv-boxes" id="srvbox1" onclick="OnChooseRide" runat="server">
当我单击(div中的任何位置)时,我在DevTool控制台中看到一条错误消息,指出“OnChooseRide未定义”。功能签名有问题吗?还有别的吗?