简体   繁体   中英

Div is not shown when button click event in asp.net page?

In my ASP page I have created one button and in click event of that button, I want to display my div tag portion.Actually that Div portion contains one text box and two buttons.

This is my aspx page content:

<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>

and My C# code is below:

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

But Whenever I click the button, the Div portion is not showing up... I dont know what is the issue here...

Please guide me to get out of this issue...

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

<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="ShowPopUp(); return false;"> </asp:Button>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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