新建一个页面,将以上代码写在form_load中客户端js中用$.ajax去访问这个页面即可。

解决方案 »

  1.   

    先学学怎么用 jquery 或者 .net 自带的ajax控件吧
      

  2.   

    <script type="text/javascript">
          $(document).ready(
            function() {
            alert("123");
               $("#Button2").click(
               function (){
                alert("456");
            var code='<%=code%>'; 
                 alert(code);
        var  txtemail= $("#txtemail").val();
            var  txtemail=document.getElementById('txtemail').value; 
                 alert(txtemail);               $.ajax({
                     type:"POST",
                    contentType:"application/json; charset=utf-8",
                     url:"advisory.aspx/Send",
                      data:"{from:'[email protected]',to:"+txtemail+",cc:'{}',body:"+code+",subject:'邮件标题',mailServer:'smtp.qq.com',port:'25',user:'12345678',password:'123456'}",  
                        dataType:'json',
                    success:function(data) {
                       if(data==1)
                      {
                          alert("发送成功"); 
                           var email=txtemail.Substring(txtemail.IndexOf('@') + 1);
                        window.location.href="http://mail.{0}"+email; 
                        }
                        
                      },
                      error: function()
                        {
                        alert("发生错误"); 
                       }
                         
                   });
                return false;  
               }
                });
            });
    </script>   <input id="Button2" type="button" value="验证"   class="btn"/>
    我执行到     $("#Button2").click(
               function (){就没法执行了是哪里出错了,链接跳转也不对
      

  3.   

      刚刚多了这个  var  txtemail=document.getElementById('txtemail').value;