Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. VS2017 Code behind function to disable check Box on Combo Box Text Value

VS2017 Code behind function to disable check Box on Combo Box Text Value

Scheduled Pinned Locked Moved ASP.NET
helpcsharpdelphiasp-net
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jason Parker 333
    wrote on last edited by
    #1

    Hello, Quick intro, My name is Jason and recently a work colleague retired and had developed several ASPX websites of which I have been tasked to support. My previous background of programming is around Delphi, Intersystems Cache and more recently C# but these websites that I'm now supporting are all written in VB.net, asp.net, aspx or whatever language it is called, as you have probably guessed by now I have never used Visual Studio or produced code that created aspx files. Anyway as a newbie to this language I have run into a problem that you experts will have learnt in school :-) I have a webpage (student.aspx) that contains this snippet of code :

    I have added the "onChange" bit and this bit of code is also existing

    So basically the page contains several combo boxes and several check boxes I need to do some logic for 2 of them, code above. If the combo box contains text (from database) with the word Nursing, Nurse, Nurses etc. lets say "*Nurs* then teh tick box needs to be disabled so it cannot be ticked This is the code I have done in the code behind file student.aspx.vb, it just contains a comment now

    Function CheckNerveCenter() As Object
        'If ID="ddlCourse" contains any word like "\*Nurs\*" then 
        'uncheck ID="chkNerveCentre" and then disable ID="chkNerveCentre"
    End Function
    

    At first I tried to get it to display a message to show that it was calling the function from the "onChange" but it doesn't seem to work. As I'm new to this language would you please just help a newbie in the right direction I did try and use the OnChangeText in visual studio but it just kept showing me this error "Property Value not valid","Error HRESULT E_FAIL has been returned from a call to a COM component." I have no idea what this means That's why I decided to try and use a function of my own but now stuck Any ideas please? Jason

    R 1 Reply Last reply
    0
    • J Jason Parker 333

      Hello, Quick intro, My name is Jason and recently a work colleague retired and had developed several ASPX websites of which I have been tasked to support. My previous background of programming is around Delphi, Intersystems Cache and more recently C# but these websites that I'm now supporting are all written in VB.net, asp.net, aspx or whatever language it is called, as you have probably guessed by now I have never used Visual Studio or produced code that created aspx files. Anyway as a newbie to this language I have run into a problem that you experts will have learnt in school :-) I have a webpage (student.aspx) that contains this snippet of code :

      I have added the "onChange" bit and this bit of code is also existing

      So basically the page contains several combo boxes and several check boxes I need to do some logic for 2 of them, code above. If the combo box contains text (from database) with the word Nursing, Nurse, Nurses etc. lets say "*Nurs* then teh tick box needs to be disabled so it cannot be ticked This is the code I have done in the code behind file student.aspx.vb, it just contains a comment now

      Function CheckNerveCenter() As Object
          'If ID="ddlCourse" contains any word like "\*Nurs\*" then 
          'uncheck ID="chkNerveCentre" and then disable ID="chkNerveCentre"
      End Function
      

      At first I tried to get it to display a message to show that it was calling the function from the "onChange" but it doesn't seem to work. As I'm new to this language would you please just help a newbie in the right direction I did try and use the OnChangeText in visual studio but it just kept showing me this error "Property Value not valid","Error HRESULT E_FAIL has been returned from a call to a COM component." I have no idea what this means That's why I decided to try and use a function of my own but now stuck Any ideas please? Jason

      R Offline
      R Offline
      Richard Deeming
      wrote on last edited by
      #2

      The OnChange event will run on the server, when the page posts back to the server. That normally only happens when you click a button; if you want it to happen as soon as your list changes, you'll need to set the AutoPostBack property of the list to True. ListControl.AutoPostBack Property (System.Web.UI.WebControls) | Microsoft Docs[^] Your event handler method will need to match the expected signature:

      Protected Sub CheckNerveCenter(ByVal sender As Object, ByVal e As EventArgs)
      ...
      End Sub


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups