Avatar of Hojoformo
 asked on

Question about OnCheckedChanged event

I have questions about events in ASP.NET.  I added an event "OnCheckedChanged" that does not get triggered until a Button event is initiated.  Is there any way to trigger the "OnCheckedChanged" event immediately when the checkbox is selected like a client side event?  For example, when the checkbox is selected, then call server method CheckBox1_CheckedChanged.  

<asp:CheckBox ID="CheckBox1" runat="server" OnCheckedChanged="CheckBox1_CheckedChanged" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click1" Text="Button" /></div>

public void CheckBox1_CheckedChanged(object sender, EventArgs e)
        DateTime todaysdate = DateTime.Now;
        TextBox2.Text = todaysdate.ToString();

Avatar of undefined
Last Comment

8/22/2022 - Mon
Bob Learned

For server-side events, you would need a post-back in order to fire the CheckedChanged event.  If you want to have it happen immediately, without a post-back, then you need to handle that client side with Javascript.


Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Your help has saved me hundreds of hours of internet surfing.