为什么我按钮点击到后台的时候总是去刷新呢,有没有什么方法可以不刷新,AJAX怎么用呢具体的,我不会啊,各位大哥救 救 小弟吧

解决方案 »

  1.   

    看看这个
    http://topic.csdn.net/u/20080831/21/73dfa3c9-93ef-4b30-8fca-4f893a8b49cf.html
      

  2.   


    $(function()

            $('#<%= TextBox3.ClientID %>').keyup(function()
            { 
                $.ajax({
                    url: 'WebService.asmx/GetInfoByName',
                    type: 'POST',
                    dataType:"xml",
                    data:{'rname':$(this).val()},
                    cache:false,
                    success: function(res)
                    {     
                        var rdiv=$('#resultDiv');
                        rdiv.html('');
                        
                        var tb="<table style='color:brown;font-size:12px;width:100%;'>"
                        $(res).find('test').each(function()  {   tb+="<tr><td>"+$(this).text()+"</td></tr>";})
                        tb+="</table>";
                        
                        rdiv.html(tb);
                        rdiv.fadeIn();
                        rdiv.offset({ top: 100, left: 300 });
                         
                        rdiv.find('td')
                        .click(function() { $('#<%= TextBox3.ClientID %>').val($(this).text()); rdiv.fadeOut(); })
                        .each(function(){ $(this).css({"cursor":"hand"});   });
                        
                        rdiv.find('tr').hover(function(){$(this).css("background-Color","honeydew");},function(){$(this).css("background-Color","");});
                    },
                    error: function(x, e)
                    {
                        alert(x.responseText);            
                    }
                });        });    
        });
      

  3.   

    取消按鈕的默認事件,可用
    function btn_click()
    {
        return false;
    }
      

  4.   

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
    </ContentTemplate>
    <Triggers>
    <asp:AsyncPostBackTrigger  ControlID="按钮ID"/>
    </Triggers>
    </asp:UpdatePanel>
      

  5.   

    page.ispostback属性应该可以控制吧
      

  6.   

    protected void Page_Load(object sender, EventArgs e)
        {    }
    里面加if(!ispostback)