Home > Net >  About ScriptManager UpdatePanel and correct use of posture, click on the Button after along with the
About ScriptManager UpdatePanel and correct use of posture, click on the Button after along with the

Time:10-09

 


<script>
The function aAjaxFun () {
Var aj.=the jQuery ajax ({
Url: 'mService asmx/aAjaxFun,
Data: {
Info: the info
},
Type: "post",
DataType: 'text',
Success: the function (data) {
Alert (" successfully saved!" );
return true;
},
Error: function () {
Alert (" save failed!" );
return false;
}
});
}
The function aAfterFun () {
Alert (1);
}
</script>

<body>

















 
Protected void Page_Load (object sender, EventArgs e)
{
That the LogManager. Write ();
}

Protected void btn1_Click (object sender, EventArgs e)
{
SQLHelper. ExecSQL (" insert into the table values' 1 '");
That the LogManager. Write ();
}
Protected void btn2_Click (object sender, EventArgs e)
{
Int a=1;
Int count=SQLHelper. ExecSQL (" insert into table1 values' "+ a +" '");
If (count & gt; 0)
{
ScriptManager. RegisterStartupScript (enclosing UpdatePanel1, enclosing GetType (), "sa", "aAfterFun ()", true);
}
That the LogManager. Write ();
}

Protected void btn4_Click (object sender, EventArgs e)
{
SQLHelper. ExecSQL (" insert into table2 values' 2 '");
That the LogManager. Write ();
}


Operation, in turn, click btn1 btn2 btn3 btn4

Js function aAfterFun () are not performed
Results aAjaxFun execution success

Log:
The 2019-07-26 19:33:34: Page_Load: 2019/7/26 19:33:34
The 2019-07-26 19:33:38: Page_Load: 2019/7/26 19:33:38
The 2019-07-26 19:33:38: btn1_Click: 2019/7/26 19:33:38
The 2019-07-26 19:33:40: Page_Load: 2019/7/26 19:33:40
The 2019-07-26 19:33:40: btn2_Click: 2019/7/26 19:33:40
The 2019-07-26 19:33:41: Page_Load: 2019/7/26 19:33:41
The 2019-07-26 19:33:42: Page_Load: 2019/7/26 19:33:42
The 2019-07-26 19:33:42: btn4_Click: 2019/7/26 19:33:42

If use UpdateMode="Conditional" more log the behind a into the Page_Load


Table1 write 1 record

If rptList have 2 record: table2 write three records

If rptList has four records: table2 write 5 records

Whether log or breakpoint that btn4_Click performed only once but table2 write multiple records incredible

CodePudding user response:

Recently found that may be something else affected but what factors can cause such effects
  •  Tags:  
  • C#
  • Related