2012-08-03 175 views
1

我有一個asp:按鈕,它具有onclick函數。有沒有辦法消除發生的刷新?擺脫刷新按鈕點擊

當前包含HTML的按鈕。

<div id="user" class="font"> 
       <div id="userPanel"> 

      <asp:TextBox ID="txtSearch" runat="server" Width="400px" align="left"></asp:TextBox> 

      <asp:Button ID="searchbutton" text="enter" runat="server" 
       onclick="searchbutton_Click" /> 

      <asp:Label ID="test" runat="server"></asp:Label> 

      </div> 

      <asp:UpdatePanel ID="userinfoupdatepanel" runat="server"> 
       <ContentTemplate> 
        <div class="topcontent"> 
         <ul>...</ul> 
        </div> 
       </ContentTemplate> 
      </asp:UpdatePanel> 

點擊該按鈕然後調用,填補了UL內容

+0

你想只調用一個javascript函數,但要回發頁面? – 2012-08-03 17:11:23

+0

它實際上在c#中調用一個函數,當前是 – user1512593 2012-08-03 17:21:02

+0

好吧,你希望它什麼都不做? – 2012-08-03 17:23:54

回答

2

您可以使用OnClientClick綁定一個JavaScript函數來處理在瀏覽器中點擊一個功能。如果您從該f return返回false,回發不會發生。

0

您還可以使用「屬性」集合添加客戶端事件。

searchbutton.Attributes.Add("onclick", "alert('Test')"); 
searchbutton.Attributes.Add("onclick", "return fnSomeThing(this);");