1

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

0

1 Answer 1

4

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>
Sign up to request clarification or add additional context in comments.

2 Comments

Wouldn't that button still do a postback, making the now-visible div hidden again once the page reloads?
@rikitikitik yeh no need to onClick method, and to prevent postback use return false; as i updated... thanks anyway

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.