_doPostBack added twice. one by manual and one by gridview in asp.net -


i have page rendering gridview. in gridview have checkbox , once check, uncheck, jquery dialog appears , need postback event on dialog. adding manual postback on page. fine till gridview has 1 page. gridview has more records, add _dopostback method on page. have 2 _dopostback method on page , nothing works because of this.

how can define in page not want add _dopostback method controls because have defined manually?

here html

<html xmlns="http://www.w3.org/1999/xhtml"> <head id="head1">     <title>store management</title>     <script src="/js/jquery-1.9.1.min.js" type="text/javascript"></script>     <script src="/js/jquery-ui.min-1.10.1.js" type="text/javascript"></script>     <link href="/assets/styles/storeportal/style-22012013.css" rel="stylesheet"     type="text/css" />     <link href="/assets/styles/storeportal/jquery-ui.css" rel="stylesheet"     type="text/css" />     <link href="../app_themes/ablecommerce/componentart.css" rel="stylesheet"     type="text/css" />     <link href="../app_themes/ablecommerce/print.css" rel="stylesheet" type=     "text/css" />     <link href="../app_themes/ablecommerce/style.css" rel="stylesheet" type=     "text/css" />     <link href="../app_themes/ablecommerce/webparts.css" rel="stylesheet" type=     "text/css" /> </head>  <body>     <form action=     "portal.aspx?q=bbaae796d951c95311f5ec3e599784079c6093ee&amp;q1=cov" id=     "form1" method="post" name="form1">         <div>             <input id="__eventtarget" name="__eventtarget" type="hidden" value=             "" /> <input id="__eventargument" name="__eventargument" type=             "hidden" value="" />         </div><script type="text/javascript"> //<![cdata[         var theform = document.forms['form1'];         if (!theform) {         theform = document.form1;         }         function __dopostback(eventtarget, eventargument) {         if (!theform.onsubmit || (theform.onsubmit() != false)) {         theform.__eventtarget.value = eventtarget;         theform.__eventargument.value = eventargument;         theform.submit();         }         }         //]]>         </script>          <div>             <input id="__viewstateencrypted" name="__viewstateencrypted" type=             "hidden" value="" />         </div>       <script type="text/javascript"> --> 1 added me manually //<![cdata[         var theform = document.forms['form1'];         if (!theform) {             theform = document.form1;         }         function __dopostback(eventtarget, eventargument) {             if (!theform.onsubmit || (theform.onsubmit() != false)) {                 theform.__eventtarget.value = eventtarget;                 theform.__eventargument.value = eventargument;                 theform.submit();             }         }         //]]>         </script>          <div>             <input id="__eventtarget" name="__eventtarget" type="hidden" value=             "" /> <input id="__eventargument" name="__eventargument" type=             "hidden" value="" /> /// code here         </div>      --> 1 added me manually     </form> </body> </html> 

now, if remove _dopostback added me, gridview paging works. when have 1 page in gridview, event in jquery dialog not work because cant find _dopostback.

answer:

i have removed _dopostback() added me , instead added on page_load() adds _dopostback() if there no asp.net controls requires method.

clientscript.getpostbackeventreference(this, string.empty); 

big @tim schmelter pointing link

i've had similar problem, when trying popup dialog confirming record deletion. code i've used (jquery ui dialog) , works perfectly. don't add new dopostback. instead, try follow idea. can adapt fit requirements:

// when user tries delete record, show confirmation. $(".confirmationbutton").click(function(e) {     // stop postback     e.preventdefault();      $(".confirmationdialog").dialog("open"); });   $(".confirmationdialog").dialog({     buttons: {     "no": function() {         $(this).dialog("close");     },     "yes": function() {         $(this).dialog("close");             // user confirmed deletion, carry on postback.             eval($("#ctl00_maincontentplaceholder_hdnbtnpostback").val());         }     } }); 

somewhere on code (when checking page source), you'll find this:

<input id="ctl00_maincontentplaceholder_hdnbtnpostback" type="hidden" value="__dopostback('ctl00$maincontentplaceholder$btndelete','')" name="ctl00$maincontentplaceholder$hdnbtnpostback"> 

that's object using eval().


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -