Server tag in OnClientClick

前端 未结 4 1648
孤独总比滥情好
孤独总比滥情好 2021-01-05 02:03

The following gives me an error of \"The server tag is not well formed\"



        
4条回答
  •  既然无缘
    2021-01-05 02:52

    Add the code dynamically in the ItemDataBound event for the ListView control.

    In your page_Load event add the following

    lst.ItemDataBound += new EventHandler(lst_ItemDataBound);
    

    Then in your ItemDataBound event handler add

    Control DeleteButton = e.Item.FindControl("DeleteButton");
    DeleteButton.OnClientClick = string.Format( "return confirm('Are you sure you want to delete '{0}'?", Username);
    

    This solution should work whether you use OnClientClick or Sachin Gaur's solution.

提交回复
热议问题