This method is really simple, but it may not be appropriate when Ajax is used. I think, let's first look at how to implement it:
<Script language = "JavaScript">
Function AA ()
{
VaR S = "<% = binddata () %> ";
Alert (s );
}
</SCRIPT>
The above is the method called:
The following method is used on the server:
Protected string binddata ()
{
Try
{
Sqlconnection con = new sqlconnection ("Server =.; uid = sa; Pwd = sa; database = test ");
Sqlcommand COM = new sqlcommand ("Update customer set Pwd = 'newpassword' where customerid = 22", con );
Con. open ();
Com. executenonquery ();
Con. Close ();
Return "modification successful ";
}
Catch
{
Return "failed to modify ";
}
}
This is a call, and it seems like an Ajax method at first glance. Actually, it is not. This method does not conform to the Ajax principle we usually call, when loading the page for the first time, it has completed the binddata () and saved the returned value to the variable S defined in Js, when we set out this JavaScript function, we will do var S = "<% = binddata () %>"; until now, I have found that only Ajax is used. dll can do a better job of requesting data on demand. I don't know if I can use XMLHTTP, but I know what I want to write. Code Too many, very cumbersome. This problem has been studied for a long time and has not been found using Ajax. dll ~~~~~~~~