简体   繁体   中英

Displaying a div on a button click in asp.net

I want to display a particular div on the click of a button
My asp code is as follows

<asp:Button ID="Button1" class="btn" runat="server" OnClick="Submit" />

<div runat="server" id="signup" Visible="false">Some Content </div>

Now in the CodeBehind i have written the following code

protected void Submit(object sender, EventArgs e)
    {
        Button1.Visible = false;
        signup.Visible = true;
    }

But every time i get the error as

the name signup does't exist in the current context

i am not able to figure out the problem in the code..

You probably have wrong html for the div , you can also use style="visible:none" instead of Visible="false"

Change

visible:"false" 

To

Visible="false"

This has to be done through JavaScript, I believe in the onClientClick attribute of the button. I'm currently searching for the code to jog my own

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