码迷,mamicode.com
首页 > 其他好文 > 详细

后台找到repeater里面的div并添加客户端点击事件

时间:2015-02-04 21:35:04      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

public partial class Inv_SelectWorkservice : System.Web.UI.Page,IPostBackEventHandler{


}


通过OnItemCreated

找到repeater里面的div并添加客户端点击事件
div要加上runat="server" id="itemTy" onclick="test"

后台:
protected void Repeater2_ItemCreated(object sender, RepeaterItemEventArgs e)
{
switch (e.Item.ItemType)
{
case ListItemType.EditItem:
break;
case ListItemType.Footer:
break;
case ListItemType.Header:
break;
case ListItemType.AlternatingItem:
case ListItemType.Item:
System.Web.UI.HtmlControls.HtmlGenericControl itemTyC = e.Item.FindControl("itemTy") as System.Web.UI.HtmlControls.HtmlGenericControl;//获取div
HiddenField hf2 = (HiddenField)e.Item.FindControl("tx_proTyId");
if (hf2 != null)
{
ViewState["proTyId"] = hf2.Value;
}
if (itemTyC != null)
{
itemTyC.Attributes["onclick"] = this.Page.ClientScript.GetPostBackEventReference(this, "ItemCe");为每一行数据添加点击事件
if (e.Item.ItemIndex==0)
{
itemTyC.Attributes["class"] ="active";
}
}
break;
case ListItemType.Pager:
break;
case ListItemType.SelectedItem:
break;
case ListItemType.Separator:
break;
default:
break;
}
}


//这个方法会更具onclick值,调用具体的业务逻辑
public void RaisePostBackEvent(string eventArgument)
{

switch (eventArgument)
{
case "test":
JSController.Alert(this, "procheck");
break;
case "ItemCe":
JSController.Alert(this, "ItemCe");
break;
default:
break;
}


}

 

后台找到repeater里面的div并添加客户端点击事件

标签:

原文地址:http://www.cnblogs.com/ctautocn/p/4273185.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!