1

関数を持つ asp:Button があり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 コンテンツを満たす関数が呼び出されます。

4

2 に答える 2

2

OnClientClickを使用して、ブラウザでのクリックを処理する Javascript 関数をバインドできます。その関数から戻った場合false、ポストバックは発生しません。

于 2012-08-03T17:13:38.183 に答える
0

Attributes コレクションを使用してクライアント イベントを追加することもできます。

searchbutton.Attributes.Add("onclick", "alert('Test')");
searchbutton.Attributes.Add("onclick", "return fnSomeThing(this);");
于 2012-08-03T17:16:41.677 に答える