Saravanan
Saravanan

Reputation: 11592

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

Upvotes: 1

Views: 2215

Answers (1)

Talha
Talha

Reputation: 19242

why should not you use OnClientClick in your asp.net button like this

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

Upvotes: 4

Related Questions