本文介绍了根据弹出窗口javascript的返回值更改asp.net面板可见性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have an asp.net website. I want to manipulate a webpage based on return value of a confirmation popup.

I have a drop down with some values. "cancel" is one of those values. So when user selects this item, a confirmation box asking user "Are you sure you want to cancel the ticket"? is displayed.

Here is my code,

HTML:

    <asp:DropDownList ID="ddlStatus" runat="server" CssClass="selectstyle" DataTextField="Name" DataValueField="ID" onchange ="GetSelectedItem(this);" />

JavaScript :

    <script type="text/javascript">
    function GetSelectedItem(x) {
        if (x.value == 4) {
            return confirm("Are you sure you want to cancel support ticket ?");
        }
    }
    </script>

which is displaying a popup as I want.

Now, I want to make a panel visible if user clicked on "OK" and reset dropdownlist if user clicked on "Cancel"

推荐答案

function GetSelectedItem(x) {
    if (x.value == 4) {
        var choice = confirm("Are you sure you want to cancel support ticket ?");
        var panel = document.getElementById("<%=TestPanel.ClientID %>");
        if (choice)
            panel.style.visibility = "hidden";
    }
}


这篇关于根据弹出窗口javascript的返回值更改asp.net面板可见性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-08 13:06