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. set value from page to webusercontrol textbox

set value from page to webusercontrol textbox

Scheduled Pinned Locked Moved ASP.NET
help
4 Posts 4 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.
  • M Offline
    M Offline
    Member 3879881
    wrote on last edited by
    #1

    Hi i am trying to set value for my user control contained textbox from my aspx page..., But i am getting error..., Whats wrong in this code: //My Aspx Code Behind: myusercontrolpage objTestControl = (myusercontrolpage)Page.FindControl("myusercontrolpage"); TextBox objTextBox = objTestControl.FindControl("TextBox5"); objTextBox.Text = "Hi"; //My Aspx Page And I have tried this logic also: Here i am getting object reference not set an instance of object..., TextBox tbPromoCode = Page.FindControl("myusercontrolpage").FindControl("TextBox1") as TextBox; tbPromoCode.Text = "BLAH"; Thanks & Regards, Member 3879881, please don't forget to vote on the post

    B E A 3 Replies Last reply
    0
    • M Member 3879881

      Hi i am trying to set value for my user control contained textbox from my aspx page..., But i am getting error..., Whats wrong in this code: //My Aspx Code Behind: myusercontrolpage objTestControl = (myusercontrolpage)Page.FindControl("myusercontrolpage"); TextBox objTextBox = objTestControl.FindControl("TextBox5"); objTextBox.Text = "Hi"; //My Aspx Page And I have tried this logic also: Here i am getting object reference not set an instance of object..., TextBox tbPromoCode = Page.FindControl("myusercontrolpage").FindControl("TextBox1") as TextBox; tbPromoCode.Text = "BLAH"; Thanks & Regards, Member 3879881, please don't forget to vote on the post

      B Offline
      B Offline
      bcozican
      wrote on last edited by
      #2

      The object reference not set an instance of object tells me that it either cannot find the myusercontrolpage control on you page or the TextBox5 control on your objTestControl. Debug and see where it happens. Depending on how your control works you can expose the textbox text property as a property on you control that returns and set the textbox value. Just an idea...

      1 Reply Last reply
      0
      • M Member 3879881

        Hi i am trying to set value for my user control contained textbox from my aspx page..., But i am getting error..., Whats wrong in this code: //My Aspx Code Behind: myusercontrolpage objTestControl = (myusercontrolpage)Page.FindControl("myusercontrolpage"); TextBox objTextBox = objTestControl.FindControl("TextBox5"); objTextBox.Text = "Hi"; //My Aspx Page And I have tried this logic also: Here i am getting object reference not set an instance of object..., TextBox tbPromoCode = Page.FindControl("myusercontrolpage").FindControl("TextBox1") as TextBox; tbPromoCode.Text = "BLAH"; Thanks & Regards, Member 3879881, please don't forget to vote on the post

        E Offline
        E Offline
        Eduard Keilholz
        wrote on last edited by
        #3

        You should create a public property on the usercontrol and set the textbox value from within the property.

        .: I love it when a plan comes together :. http://www.zonderpunt.nl

        1 Reply Last reply
        0
        • M Member 3879881

          Hi i am trying to set value for my user control contained textbox from my aspx page..., But i am getting error..., Whats wrong in this code: //My Aspx Code Behind: myusercontrolpage objTestControl = (myusercontrolpage)Page.FindControl("myusercontrolpage"); TextBox objTextBox = objTestControl.FindControl("TextBox5"); objTextBox.Text = "Hi"; //My Aspx Page And I have tried this logic also: Here i am getting object reference not set an instance of object..., TextBox tbPromoCode = Page.FindControl("myusercontrolpage").FindControl("TextBox1") as TextBox; tbPromoCode.Text = "BLAH"; Thanks & Regards, Member 3879881, please don't forget to vote on the post

          A Offline
          A Offline
          Abhijit Jana
          wrote on last edited by
          #4

          create a public property on your user control and set the value from the page. :)

          cheers, Abhijit

          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