繁体   English   中英

弹出式广告的Javascript。 用于Visual Studio 2005的Asp.net

[英]Javascript for a popup. Asp.net for Visual Studio 2005

单击链接时必须为弹出窗口编写什么JavaScript? 纠正我是否还有其他事情要做。

链接是这样写的。

<div style="float:left; padding-left:9px;">
    <asp:LinkButton ID="lnkActiveInactive" runat="server" OnClick="lnkActiveInactive_Click"
      CssClass="linkclass" Font-Underline="True">Cancel My Account</asp:LinkButton>
</div>

弹出式扩展程序就是这样。

<cc1:ConfirmButtonExtender DisplayModalPopupID="ModalPopupExtender2" ID="ConfirmButtonExtender2"
    runat="server" TargetControlID="lnkActiveInactive">
</cc1:ConfirmButtonExtender>
<cc1:ModalPopupExtender ID="ModalPopupExtender2" OkControlID="btnYesCancel" CancelControlID="btnNoCancel"
    BackgroundCssClass="modalBackground" PopupControlID="pnlCancelPopup" TargetControlID="lnkActiveInactive"
    runat="server">
</cc1:ModalPopupExtender>

<asp:Panel CssClass="modalPopup" ID="pnlCancelPopup" runat="server">
    <!-- Common Popup Control Begin -->
    <table class="tblCommonPopup" width="690px" cellpadding="0" cellspacing="0">
        <tr>
            <td class="topLeft">
            </td>
            <td class="topMiddle">
            </td>
            <td class="topRight">
            </td>
        </tr>
        <tr>
            <td colspan="3" class="middle" align="center">
                <!-- Content Area Begin -->
                <table>
                    <tr>
                        <td>
                        </td>
                        <td colspan="2" style="padding-top: 10px;">
                            <table width="100%">
                                <tr>
                                    <td align="center">                                             
                                         Feel free to change your package to Basic, there is no charge for this Package.<br /><br />If you still wish to cancel, 
                                         your account will become inactive within DealTown and any further billing will <br />discontinue.  
                                         We will keep you account in our system for some time if you wish to active it again.<br /><br />Are you sure you 
                                         wish to cancel your account?                                                                                           
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td align="center" colspan="4">
                            <input id="btnYesCancel" type="button" value="YES" class="popupButton" />
                            <input id="btnNoCancel" type="button" value="NO" class="popupButton" />
                        </td>
                    </tr>
                </table>
                <!-- Content Area Ends -->
            </td>
        </tr>
        <tr>
            <td class="bottomLeft">
            </td>
            <td class="bottomMiddle">
            </td>
            <td class="bottomRight">
            </td>
        </tr>
    </table>
    <!-- Common Popup Control End -->
</asp:Panel>

我不确定我是否清楚地理解了您的问题,但这是如何在JS中弹出

    <script type="text/javascript">
    <!--
    function Confirmation() {
        var answer = confirm("Are you sure you want to Cancel your Account?")
        if (answer){
            alert("Goodbye!")
        }
        else{
            alert("Thanks for not Cancelling")
        }
    }
    //-->
    </script>
    <div style="float:left; padding-left:9px;">
<asp:LinkButton ID="lnkActiveInactive" onclick="Confirmation();">Cancel My Account</asp:LinkButton>
</div>

如果您在客户端运行,则使用此代码。 如果您希望它在服务器端运行,则必须在这样的代码背后进行操作

if (!IsPostBack) {
    this.lnkActiveInactive.Attributes.Add("onclick", "javascript:Confirmation()");
}

如果您只需要“取消我的帐户”的确认对话框,则只需在aspx页面中放置一些JavaScript。

就像是:

onclick =“ javascript:confirm()”

希望这可以帮助!

我认为其他响应者都错过了您使用的是ASP.NET Ajax工具包ModalPopupExtender。

您的问题的答案是,不,不需要Javascript。 将ModalPopupExtender的TargetControlID设置为LinkBut​​ton应该足以使弹出窗口出现。 如果这没有发生,那是其他错误。

我注意到的一件事是,LinkBut​​ton上有一个OnClick处理程序。 如果链接按钮的唯一功能是弹出对话框,则不必这样做。

暂无
暂无

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

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