按钮

时间:2022-01-22 21:04:10

I am creating an ASP.NET with C# calendar application. When a user clicks on a day, I am using a jQuery Popup Overlay which will allow the user to add an 'appointment' and click a button to process the entered information in the codebehind.

我正在创建一个ASP。NET与c#日历应用程序。当用户单击某一天时,我使用的是jQuery Popup覆盖,它允许用户添加一个“约会”,并单击一个按钮来处理在代码后面的输入信息。

The Popup overlay basically hides an HTML element and makes it visible when another element is clicked (great examples by following link above).

弹出窗口覆盖层基本上隐藏了一个HTML元素,并使它在单击另一个元素时可见(上面的链接就是很好的例子)。

The Code:

代码:

<asp:Button ID="ButtonA" runat="server" OnClick="Button_Click" Text="Button A" />
<asp:Label ID="Label" runat="server" Text="Foo"></asp:Label>

<div id='slide'>        
    <div id="content">
        Content of the 'popup panel'
        <asp:Button ID="ButtonB" runat="server" OnClick="Button_Click" Text="Button B" />
    </div>
</div>

CodeBehind:

后台代码:

public void Button_Click(Object sender, EventArgs e)
{
    Label.Text = "Bar"; 
}

Javascript:

Javascript:

$(document).ready(function () {
    $('#slide').popup({
        //options
    });
});

I tried adding the AutoPostBack="true" parameter to the buttons, but it doesn't make a difference (should be automatic regardless, correct?). I also tried adding the runat="server" parameter to the div elements, but that made the issue worse.

我试着在按钮上添加了AutoPostBack="true"参数,但它并没有造成什么区别(应该是自动的,对吗?)我还尝试向div元素添加runat=“server”参数,但这使问题变得更糟。

I am afraid that I don't understand the nature of the issue enough to provide more information than this - Sorry!

我恐怕我不明白这个问题的性质,足以提供比这更多的信息——对不起!

1 个解决方案

#1


1  

It's likely that the jQuery plugin is overriding the behaviour of the button. You could use the onclose callback from the URL you provided to have a function like so:

jQuery插件很可能会覆盖按钮的行为。您可以使用您提供的URL的onclose回调来实现如下功能:

function() {
    __doPostBack("ctl00$MainContent$ButtonB","");
}

Failing that, you could have another button outside the popup div which you do a click() event on manually during the onclose event of the popup, but that seems like a bit of a hack!

如果做不到这一点,您可以在弹出框div之外有另一个按钮,您可以在弹出框的onclose事件期间手动单击()事件,但这似乎有点麻烦!

#1


1  

It's likely that the jQuery plugin is overriding the behaviour of the button. You could use the onclose callback from the URL you provided to have a function like so:

jQuery插件很可能会覆盖按钮的行为。您可以使用您提供的URL的onclose回调来实现如下功能:

function() {
    __doPostBack("ctl00$MainContent$ButtonB","");
}

Failing that, you could have another button outside the popup div which you do a click() event on manually during the onclose event of the popup, but that seems like a bit of a hack!

如果做不到这一点,您可以在弹出框div之外有另一个按钮,您可以在弹出框的onclose事件期间手动单击()事件,但这似乎有点麻烦!