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. General Programming
  3. C#
  4. Updating Controls included in other controls

Updating Controls included in other controls

Scheduled Pinned Locked Moved C#
helpannouncement
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.
  • V Offline
    V Offline
    veroBT
    wrote on last edited by
    #1

    I have a user control that i created which contains a bunch of search varibles in the form of text boxes and drop-down lists. I include this control in the search page and a couple of others. I am trying to update the value of the textbox and drop down lists within this user control and can't. I have been able to read the values of the Controls using: Control myKeywords = FindControl("ctl_search:tb_keywords"); TextBox tb_keywords = (TextBox)myKeywords; tb_keywords.Text.ToString(); But I need to update the value of those controls. Any help you can provide would be greatly appreciated!

    H 1 Reply Last reply
    0
    • V veroBT

      I have a user control that i created which contains a bunch of search varibles in the form of text boxes and drop-down lists. I include this control in the search page and a couple of others. I am trying to update the value of the textbox and drop down lists within this user control and can't. I have been able to read the values of the Controls using: Control myKeywords = FindControl("ctl_search:tb_keywords"); TextBox tb_keywords = (TextBox)myKeywords; tb_keywords.Text.ToString(); But I need to update the value of those controls. Any help you can provide would be greatly appreciated!

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Why are you using Text.ToString? Text already returns a string. This is a waste of CPU cycles. If you're getting back a value (i.e., not null) from FindControl, then just set cast to a TextBox as you're doing and set Text to some string, like tb_keywords.Text = "Some string";.

      Microsoft MVP, Visual C# My Articles

      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