Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7184795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:16:30+00:00 2026-05-28T18:16:30+00:00

Environment: .NET 2.0, visual studio 2005 in aspx markup, set a control like: <asp:CheckBox

  • 0

Environment: .NET 2.0, visual studio 2005

in aspx markup, set a control like:

<asp:CheckBox ID="E287" runat="server"  />

in code behind, hook up event to a javascript func in Page_Load event like:

Me.E287.Attributes.Add("OnCheckedChanged", "javascript:alert(123);")

then test the page in browser, and click on the checkbox, no response. check the source, it is:

<span OnCheckedChanged="javascript:alert();"><input id="E287" type="checkbox" name="E287" /></span>

can’t understand.

If change aspx markup like:

<asp:CheckBox ID="E287" runat="server" OnCheckedChanged="javascript:alert(123);" />

will get error

BC30456: ‘javascript’ is not a member of ‘ASP.MyPage_aspx’.

Really confused. How to resolve this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:16:31+00:00Added an answer on May 28, 2026 at 6:16 pm

    As you see the rendered control the javascript go to the span (label), to add it to the input/check box you need to use the InputAttributes. Also on the client side you need to use the onchange or the onclick to get the results you looking for.

    E287.InputAttributes
    

    so it will be

    Me.E287.InputAttributes.Add("onchange", "javascript:alert('123');")
    

    Thats because the check box use 2 controls to render, one span and one input, so with your code you add on the text the script and not on check box.
    There also the LabelAttributes. Here the Attributes are go to the span, because span is parent of input.

     E287.LabelAttributes
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Environment: C# projects, Visual studio 2008, C#, .Net 3.5, MSBuild Objective: Run my own
On a Windows Server 2003 R2 with .NET 4 SDK but without Visual Studio
Environment Windows XP SP3 x32 Visual Studio 2005 Standard Device/Platform: Honeywell Dolphin 9500 with
Environment Windows XP x32 Visual Studio 2005 Standard Edition Honeywell Dolphin 9500 running Windows
Environment Windows XP x32 Visual Studio 2005 Standard Edition Honeywell Dolphin 9500 running Windows
Environment: Visual Studio Ultimate 2010 .NET 4.0 Windows XP, Vista and 7 We have
Environment: Windows 7 SP1 Visual Studio 2010 Ultimate SP1 .NET 4.0 I have a
We have an in-house .net 2.0 winforms app currently developed on Visual Studio 2005
In every Visual Studio.NET version you can set keyboard shortcuts using menu Tools ->
For an ASP.Net environment what permissions should the logging file created by NLog have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.