Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
when button clicked class properties dont change else reload same class in asp.net c# codebehind

 <div class="demo" id ="demo" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
   <asp:Button ID="BtnDemo" runat="server" OnClick="BtnDemo_Click" />
</asp:UpdatePanel>
</div>


i just want button clicked div class demo activate in codebehind in asp.net but i have tried all the methods but just cant do it. Ples anyone help. Thanks for your support.


protected void BtnDemo_Click(object sender, EventArgs e)
{
    if (BtnDemo_Click.Text == "Next")
    {
        demo.Attributes.Add("class", "demo");        
        demo.Visible = true; 
        
    }
}


What I have tried:

protected void BtnDemo_Click(object sender, EventArgs e)
{
    if (BtnDemo_Click.Text == "Next")
    {
        demo.Attributes.Add("class", "demo");        
         demo.Visible = true;  
        
    }
}
Posted
Updated 15-Jul-22 8:57am
v3
Comments
0x01AA 12-Jul-22 14:06pm    
And you are sure that

1. -- demo.Attributes.Add("class", "demo");
2. -- demo.Visible = true;
3. -- demo.Style("display") = "none";
4. -- demo.Attributes("style") = "display:block";
5. -- demo.Attributes("class") = " ";
6. -- demo.Attributes.Remove("class");
compiles?
Vinoth S 2022 12-Jul-22 14:12pm    
protected void BtnDemo_Click(object sender, EventArgs e)
{
if (BtnDemo_Click.Text == "Next")
{
demo.Attributes.Add("class", "demo");
demo.Visible = true;

}
}
Vinoth S 2022 12-Jul-22 14:14pm    
i have upload the question for example purpose only. but i need when button clicked class properties in div dont change else reload same class when button clicked in asp.net c# codebehind

An UpdatePanel only updates the elements within the panel. Since your demo element is outside of the panel, changes to that element made during a partial postback will not have any effect.

Understanding Partial Page Updates with ASP.NET AJAX | Microsoft Docs[^]
 
Share this answer
 
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<div class="demo" id ="demo" runat="server">
   <asp:Button ID="BtnDemo" runat="server" OnClick="BtnDemo_Click" />
</div>
</asp:UpdatePanel>
</div>


when i used inside updatepanel demo class shouldnot change how to do it
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900