0

Ascx:

<div id="temasatratar" onclick="__doPostBack('fakeButton', '');"><h1>Temas a tratar</h1></div>
<asp:LinkButton ID="fakeButton" style="display:none" runat="server" Text="foo" OnClick="fakeButton_Click" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" onload="UpdatePanel1_Load">
    <ContentTemplate>
        <asp:Label runat="server" ID="Label1" />
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="fakeButton" />
    </Triggers>
</asp:UpdatePanel>

后面的代码:

    protected void fakeButton_Click(Object sender, EventArgs e)
    {
        UpdatePanel1.Update();
    }

    protected void UpdatePanel1_Load(object sender, EventArgs e)
    {
        Random ran = new Random();
        int x = ran.Next(9999);
        Label1.Text = x.ToString();
    }

问题:代码完全充值页面,没有UploadPanel1。怎么只充值UploadPanel1?

有什么建议吗?

我的应用程序:C#/Visual web Part/Asp.Net/Visual Studio

4

2 回答 2

0

尝试这个:

<div id="temasatratar"><h1>Temas a tratar</h1></div>
<asp:Button ID="fakeButton" style="display:none" runat="server" Text="foo" OnClick="fakeButton_Click"/>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" onload="UpdatePanel1_Load" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Label runat="server" ID="Label1" />
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="fakeButton" />
    </Triggers>
</asp:UpdatePanel>


<script type="text/javascript">
    function pageLoad() {
        $('#temasatratar').click(function () {
            console.log('clicked');
            $('#<%= fakeButton.ClientID %>').click();
        });
    }
</script>
于 2013-07-04T16:25:07.883 回答
0

According to this MSDN article, I believe you are missing the scriptmanager control.

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
于 2013-07-04T15:34:30.133 回答