1

在我的 ASP 页面中,我创建了一个按钮,在该按钮的单击事件中,我想显示我的 div 标签部分。实际上,该 Div 部分包含一个文本框和两个按钮。

这是我的 aspx 页面内容:

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<style type="text/css">
#popup
{
    display:none;
    position: fixed;
    width:250px;
    height: 150px;
    top: 50%;
    left: 50%;
    margin-left:-155px;
    margin-top:-110px;
    border:5px solid red;
    background-color:#DEDFDE;
    padding:30px;
    z-index:102;
    font-family:Verdana;
    font-size:10pt;
    -webkit-border-radius:20px;
    -moz-border-radius:20px;
    font-weight:bold;
}
#content
{
    height:auto;
    width:250px;
    margin:60px auto;
}
#popupclose
{
    margin:35px 0 0 80px;
    width:50px;

}
</style>
</asp:Content>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">

<script type="text/javascript" language="javascript">
    function ShowPopUp()
    {
      $('#popup').show("slow");
    }

    function hidePopUp()
    {
       $('#popup').hide("slow");
    }
</script>


    <asp:Button ID="Button1" runat="server" Text="Button" onclick="Test">
    </asp:Button>

   <div id="popup">
        <div id="content">
            <input type="text"/><input type="button" value="Browse"/>
            <input id="popupclose" type="button" value="Close" onclick="hidePopUp();/>   
        </div>   
   </div>

</asp:Content>

我的 C# 代码如下:

 protected void Test(object sender,EventArgs e)
        {
         ClientScript.RegisterStartupScript(GetType(), "popup", "ShowPopUp()", true);
        }

但是每当我单击按钮时,Div 部分都没有出现......我不知道这里有什么问题......

请指导我摆脱这个问题......

4

1 回答 1

4

你为什么不应该OnClientClick像这样在你的 asp.net 按钮中使用

<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="ShowPopUp(); return false;"> </asp:Button>
于 2012-11-22T07:17:20.877 回答