user187707
user187707

Reputation:

Insert Javascript in ASP.net

I am using visual basic for coding. In my form I have a delete button for deleting a record. Now I want to show a Confirm msgbox using javascript instead of using visual basic.

What is the javascipt code for the msgbox & Where do I insert this code?

Upvotes: 0

Views: 261

Answers (3)

Himadri
Himadri

Reputation: 8876

Try this:

<asp:Button ID="btnDelete" runat="server" Text="Delete" OnClientClick="javascript:return confirm('Are you sure you want to delete this record?');" />

Upvotes: 1

Darin Dimitrov
Darin Dimitrov

Reputation: 1038830

<asp:LinkButton 
    ID="LinkButton1" 
    runat="server" 
    OnClick="LinkButton_Click"
    OnClientClick ="return confirm('Are you sure to delete ?')"
    Text="Delete" 
/>

Upvotes: 1

Muhammad Akhtar
Muhammad Akhtar

Reputation: 52241

try this..

<asp:Button runat="server" ID="btnDelete" Text="Delete" OnClientClick="return confirm(&quot;Are you sure you want to delete&quot;)" />

If you want in code behind

imgbtn.Attributes.Add("onClick", "javascript:return confirm('Are you sure you want to delete ?');");

Upvotes: 4

Related Questions