|
 |
aspx_beginners thread: aspx dialog box
Message #1 by michel.grootjans@a... on Wed, 16 Oct 2002 10:41:16
|
|
I have a datagrid with a 'delete' button for each record. I want to ask
user confirmation when he/she clicks on this button.
Is it possible to have a DialoBox/MessageBox pop up to ask for
confirmation? Is this the best solution?
Message #2 by mvermef@h... on Mon, 21 Oct 2002 09:15:49
|
|
> I have a datagrid with a 'delete' button for each record. I want to ask
u> ser confirmation when he/she clicks on this button.
> Is it possible to have a DialoBox/MessageBox pop up to ask for
c> onfirmation? Is this the best solution?
Oh yes...
C# solution only...
In the event ItemDataBound place the following code to catch first
whether or not the HyperLink exists as an object. If it does then you
will attach the code to the "ONCLICK" event in javascript:
(((((((((((((((((((((( Shows How to Capture a Templated Column ))))))))))
if(e.Item.FindControl("delLink") != null)
{
((LinkButton) e.Item.FindControl("delLink")).Attributes.Add
"onClick", "return confirm('Are you sure you wish to delete this
item?');");
}
(((((((((((((((((((((Shows how to capture non-templated column)))))))))))
if(e.Item.Cell[x].Controls[0] != null)
{
((LinkButton) e.Item.Cell[x].Controls[0]).Attributes.Add
"onClick", "return confirm('Are you sure you wish to delete this
item?');");
}
hth
Morgan
Message #3 by michel.grootjans@a... on Wed, 23 Oct 2002 13:34:50
|
|
Can this be done in the HTML editor of Visual Studio. When I add
an 'onClick' event, it doesn't show in Intellisense and it gets underlined
in red.
<body>
<form id="Form1" method="post" runat="server">
<asp:datagrid id="dgrTransporter" runat="server"
AutoGenerateColumns="False" >
<Columns>
<asp:EditCommandColumn
ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel"
EditText="Edit"></asp:EditCommandColumn>
<asp:ButtonColumn Text="Delete"
CommandName="Delete"></asp:ButtonColumn>
<asp:BoundColumn
DataField="ID_TR_TRANSPORTER" ReadOnly="True"
HeaderText="ID"></asp:BoundColumn>
<asp:BoundColumn DataField="TRANSP_NAME"
HeaderText="Name"></asp:BoundColumn>
<asp:BoundColumn DataField="ADDRESS"
HeaderText="Address"></asp:BoundColumn>
<asp:BoundColumn DataField="EMAIL"
HeaderText="e-mail"></asp:BoundColumn>
<asp:BoundColumn DataField="TEL"
HeaderText="Tel 2"></asp:BoundColumn>
<asp:BoundColumn DataField="FAX"
HeaderText="Fax"></asp:BoundColumn>
<asp:BoundColumn DataField="CONTACT"
HeaderText="Contact"></asp:BoundColumn>
</Columns>
</asp:datagrid></form>
</SCRIPT>
</body>
|
|
 |