我怎样才能在我的Web应用程序中使用ajax工具包控件?

时间:2014-05-08 14:59:39

标签: c# asp.net ajax vb.net ajaxcontroltoolkit

我正在尝试在我的ASP .net应用程序中使用一些Ajax工具包控件,但似乎它不起作用。
我想在我的表单中使用Modal弹出窗口,但必须在弹出窗口中显示的面板,在浏览器上显示,按钮不执行任何操作。为什么它不起作用?
我正在编写VB .net并且有我的样本:

    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="FieldItem.ascx.vb" Inherits="DataBaseWorker.FieldItem" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
    <link href="../Styles/FieldItem.css"  rel="stylesheet" type="text/css" />
    <div class="TitleDiv">

<span runat="server" id="lblIndex" class="IndexSpan">111</span>
<span runat="server" id="lblDelimeter" class="IndexSpan"> ) </span>
<span runat="server" id="lblTitle" class="TitleSpan">test</span>
<span runat="server" id="lblActiveState" class="TitleSpan">test</span>
<span runat="server" id="lblAlias" class="TitleSpan">test</span>
<asp:Button CssClass="buttonControl" ID="btnDelete" runat="server" Text="test" />
<asp:Button CssClass="buttonControl" ID="btnEdit" runat="server" Text="test" />
<asp:Button CssClass="buttonControl" ID="btnAddAlias" runat="server" Text="test" />
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
 CancelControlID="btnCancel" OkControlID="btnSubmitAlias" TargetControlID="btnAddAlias"
  PopupControlID="addAliasPlace" Drag="false">

  <Animations>
                <OnShowing>
                    <Sequence>
                        <StyleAction AnimationTarget="CloseButton" Attribute="display" Value="none" />
                        <Resize Duration="0" Height="50px" Width="50px" />
                    </Sequence>
                </OnShowing>
                <OnShown>
                    <Sequence>
                        <Parallel>
                            <FadeIn />
                            <Scale ScaleFactor="5" Center="True" />
                        </Parallel>
                        <StyleAction AnimationTarget="CloseButton" Attribute="display" Value="" />
                    </Sequence>
                </OnShown>    
                <OnHiding>
                    <Sequence>                            
                        <StyleAction AnimationTarget="CloseButton" Attribute="display" Value="none" />
                        <Parallel>
                            <FadeOut />
                            <Scale ScaleFactor="5" Center="True" />
                        </Parallel>
                    </Sequence>
                </OnHiding>            
        </Animations>

</asp:ModalPopupExtender>

    </div>
<asp:Panel Visible="false"  runat="server" id="addAliasPlace" >

<div  class="AddAliasDiv">
    <asp:TextBox ID="txtAliasName" CssClass="TitleSpan" runat="server"></asp:TextBox>
    <asp:Button CssClass="buttonControl" ID="btnSubmitAlias" runat="server" Text="ثبت" />
    <asp:Button CssClass="buttonControl" ID="btnCancel" runat="server" Text="بازگشت" />
</div>
</asp:Panel>

2 个答案:

答案 0 :(得分:0)

我可以描述当我使用模态弹出时我做了什么。

<asp:Button ID="btnshowpopup" runat="server" Style="display: none;" />


<act:ModalPopupExtender ID="test" runat="server"
       TargetControlID="btnshowpopup"
       PopupControlID="addAliasPlace"
       CancelControlID="btnModalCancel"
       BackgroundCssClass="modalBackground"
       BehaviorID="addAliasPlace">
   </act:ModalPopupExtender>

在我使用js显示模态后,例如:

$find("addAliasPlace").show();

答案 1 :(得分:0)

如果是用户控件,则必须使用System.Web.UI.ScriptControl。

来自pietschsoft.com: ScriptControl基类在派生控件的PreRender阶段测试ScriptManager控件的页面。 ScriptControl基类还确保派生控件调用ScriptManager控件的方法以在Render事件期间注册脚本。这包括在调用Render方法时为ScriptControl注册ScriptDescriptor对象。除非呈现ScriptControl本身,否则Render方法确保不呈现ScriptDescriptor对象。这使得ScriptControl可以在封闭的WebPart控件中工作。

参见: http://pietschsoft.com/post/2008/05/15/ASPNET_Create_AJAX_Server_Controls_using_the_ScriptControl_base_class