0

Hi Dudes i need a javascript code for code behind using c#.When user click on delete button the popup dialog open Do you really want to delete Yes/No on Yes i want to put my Delete Method there.Pls help me.Thanks in advance.

5
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by nakor77
0

The Button Control has two properties, OnClick="ServerSideMethod" OnClientClick="ClientSideMethod". So in the OnClick put your Delete Method and in the OnClientClick="return Confirm('Are you sure want to delete');" or call the javascript function...

0

You can use OnClientClick to call a script function at the java script tag of the asp.net

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

<script type="text/javascript">


function func1() {

    window.alert('Hello World !');
}

</script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Button ID="Button1" runat="server" 
   OnClientClick= "return func1();" 
    Text="Button" />
    <p>
    </p>
</asp:Content>

The above source for aspx page for a web form has a button when clicked a java script window will appear

Edited by omar isaid: n/a

1

if you are using Update Panel then

ScriptManager.RegisterClientScriptBlock(this,getType(),"Key","alert('it is working')","true");

if not using update panel then

page.clientscript.registerstartupscript(getType(),,"Key","alert('it is working')","true");

hope that helps

Votes + Comments
i like it, but should there be an empty space between two commas on the second example?
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.