Ibrahim Shaikh Ibrahim Shaikh - 1 year ago 185
ASP.NET (C#) Question

use data-target and data-toggle on asp:buttonfield

i am creating a web app in which i want to open a modal on button click, the button is inside grid

<asp:ButtonField Text="Expense" data-toggle="modal" data-target="#myModal" CommandName="Select" />

this is my button in which i want to open the bootstrap modal but when i debug my program i am getting the following error

Parser Error

Description: An error occurred during the parsing of a resource
required to service this request. Please review the following specific
parse error details and modify your source file appropriately.

Parser Error Message: Type 'System.Web.UI.WebControls.ButtonField'
does not have a public property named 'data-toggle'.

Line 259: SortExpression="status" />
Line 260: <asp:BoundField DataField="clash" HeaderText="clash" SortExpression="clash" Visible="false" />
Line 261: <asp:ButtonField Text="Expense" data-toggle="modal" data-target="#myModal" CommandName="Select" />
Line 262: <asp:ButtonField Text="Expense Details" CommandName="Details" />
Line 263: </Columns>

any help?

Answer Source

I did a similar thing a while back but instead of using the data-toggle functionality I called the scripts from the code-behind using the following:

ScriptManager.RegisterStartupScript(this, this.GetType(), "ModalView", "<script>$('#ViewEnqDetail').modal('show');</script>", false);

Before the above line you can populate any controls on your modal with data that you would like to show.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download