What would be best approach to write JQuery Code in asp.net for Inser,Edit and Delete operation? -


i have 3 button insert,edit , delete on sample.aspx page in .net application.i doing client side operation on every button click event using jquery.what best approach write jquery code performance point of view.

1.)should write separate click event each button click given below

$("#btninsert").click(function(){     //insertcode }); $("#btnedit").click(function(){     //edit code }); $("#btndelete").click(function(){     //delete code }); 

2.) should write common function given below

$("#btninsert").click(function(){     operation("i") }); $("#btnedit").click(function(){     operation("e") }); $("#btndelete").click(function(){     operation("d") }); function operation(optype) {     if( optype = "i")     {         //insert     }     if( optype = "e")     {         //edit     }     if( optype = "d")     {         //delete     } } 

3.)should use onclientclick event of every button

<asp:button id="btninsert" runat="server" text="insert" onclientclick="return operation("i");" /> <asp:button id="btnedit" runat="server" text="edit" onclientclick="return operation("e");" /> <asp:button id="btndelete" runat="server" text="delete" onclientclick="return operation("d");" /> 

or

is there other optimization technique?

thanks

i in first choice:

$("btninsert").click(function(){     //insertcode }); $("btnedit").click(function(){     //edit code }); $("btndelete").click(function(){     //delete code }); 

option 2 seems bloated me. , option 3 defeats point of jquery!


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -