简体   繁体   English

在asp.net中单击按钮时显示div

[英]Displaying a div on a button click in asp.net

I want to display a particular div on the click of a button我想在单击按钮时显示特定的 div
My asp code is as follows我的asp代码如下

<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现在在 CodeBehind 中,我编写了以下代码

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"你可能有错误的div html ,你也可以使用style="visible:none"而不是 Visible="false"

Change改变

visible:"false" 

To

Visible="false"

This has to be done through JavaScript, I believe in the onClientClick attribute of the button.这必须通过 JavaScript 完成,我相信按钮的 onClientClick 属性。 I'm currently searching for the code to jog my own我目前正在寻找自己慢跑的代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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