简体   繁体   English

AjaxToolkit选项卡控件作为按钮

[英]AjaxToolkit Tab Control as Button

I am currently building a tab control with multiple tab panels, and would like to have one of the tabs as a button instead of a template with content. 我目前正在构建具有多个标签面板的标签控件,并且希望将其中一个标签作为按钮而不是具有内容的模板。 The idea being that when the user clicks on the tab with the button, an event would fire and a C# method would run, and the page would post back. 这样的想法是,当用户单击带有按钮的选项卡时,将触发事件并运行C#方法,并且页面将回发。

How would I go about doing this? 我将如何去做呢? Preferably this could be something generated in the code behind as all the other tabs are programmatically generated along with the content. 最好是在后面的代码中生成某些内容,因为所有其他选项卡都与内容一起以编程方式生成。

You can handle TabContainer's ActiveTabChanged event. 您可以处理TabContainer的ActiveTabChanged事件。 Therefore you need to set AutoPostBack for the TabContainer to true. 因此,您需要将TabContainer的AutoPostBack设置为true。

<asp:TabContainer ID="TabContainer1" runat="server" AutoPostBack="true" OnActiveTabChanged="ActiveTabChanged">

Codebehind: 代码背后:

protected void ActiveTabChanged(object sender, EventArgs e)
{
    if (TabContainer1.ActiveTabIndex == 0)
    {
        // ...
    }
    // ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM