Sunday, March 11, 2012

Questions on ModalPopupExtender control.

Question 1: I do something similar to what you are looking for by generating the required javascript during the repeater's ItemDataBound event.

public void Page_PreRender(object sender, EventArgs e) {string script ="<script>" + clientScript.ToString() +"</script>"; Page.ClientScript.RegisterStartupScript(GetType(),string.Empty, script); }private readonly StringBuilder clientScript =new StringBuilder();private void OrderList_ItemDataBound(object sender, RepeaterItemEventArgs e) {if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Label OrderId = (Label) e.Item.FindControl("OrderId"); Label Description = (Label) e.Item.FindControl("Description"); LinkButton DeleteOrder = (LinkButton) e.Item.FindControl("DeleteOrder"); Order o = (Order) e.Item.DataItem; OrderId.Text = o.OrderId.ToString(); Description.Text = o.Description; DeleteOrder.CommandArgument = o.OrderId.ToString(); DeleteOrder.CommandName ="CANCEL"; clientScript.Append("$addHandler($get(\"" + DeleteOrder.ClientID + "\"), 'click', showModalPopupViaClient);"); } }
The full example is herehttp://blog.joelowrance.com/archive/2007/07/10/ajax-modalpopupextender-in-a-repeater.aspx

No comments:

Post a Comment