根据弹出窗口javascript的返回值更改asp.net面板可见性 [英] change asp.net panel visibility based on return value of popup window javascript

查看:63
本文介绍了根据弹出窗口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"

推荐答案

您需要引用该面板,然后设置控件的Style visibility属性



You need to reference the panel and then set the Style visibility property of the control

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面板可见性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆