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. Setting dynamic Text Box after post backs

Setting dynamic Text Box after post backs

Scheduled Pinned Locked Moved C#
css
3 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.
  • T Offline
    T Offline
    TheMajorRager
    wrote on last edited by
    #1

    Hello everyone. It's me again, and on my project teh user is suppose to press a button, and then when the post back occurs I check what the user entered in in the dynamic text box, and if it is less than a certain number it should put a different number that is valid in. Let's say the user enters in 10, but the minimum number to enter in is 15, it should put that number in the text box. I tried Request.Form.Set() but that is apparently read-only so that did not work. Thanks. Sincerely, The Major Rager

    W 1 Reply Last reply
    0
    • T TheMajorRager

      Hello everyone. It's me again, and on my project teh user is suppose to press a button, and then when the post back occurs I check what the user entered in in the dynamic text box, and if it is less than a certain number it should put a different number that is valid in. Let's say the user enters in 10, but the minimum number to enter in is 15, it should put that number in the text box. I tried Request.Form.Set() but that is apparently read-only so that did not work. Thanks. Sincerely, The Major Rager

      W Offline
      W Offline
      whizzs
      wrote on last edited by
      #2

      Are you having trouble checking the value? If so, use the RangeValidator class, you can set the control for it to validate, maximum value and minimum value. If the value of the text box is outside the range, you can set the value of the text box to the minimum. I would do this in the page_load section in an if block "if (Page.IsPostBack)" ex if ( Page.IsPostBack ) { rangevalidator.ControlToValidate = "textbox1"; rangevalidator.MaximumValue = "100"; rangevalidator.MinimumValue = "15"; if ( rangevalidator.IsValid ) { // do your thing } else { textbox1.Text = "15"; rangevalidator.ErrorMessage = "whatever you want to tell the user"; } }

      T 1 Reply Last reply
      0
      • W whizzs

        Are you having trouble checking the value? If so, use the RangeValidator class, you can set the control for it to validate, maximum value and minimum value. If the value of the text box is outside the range, you can set the value of the text box to the minimum. I would do this in the page_load section in an if block "if (Page.IsPostBack)" ex if ( Page.IsPostBack ) { rangevalidator.ControlToValidate = "textbox1"; rangevalidator.MaximumValue = "100"; rangevalidator.MinimumValue = "15"; if ( rangevalidator.IsValid ) { // do your thing } else { textbox1.Text = "15"; rangevalidator.ErrorMessage = "whatever you want to tell the user"; } }

        T Offline
        T Offline
        TheMajorRager
        wrote on last edited by
        #3

        Hi, thanks for replying to my message. I actually used this ((TextBox)(Page.FindControl(identity))); where identity was the name of the text box and I was able to get and cast the control as a text box and then manipulate the data in it. Thanks a lot for replying however! Sincerely, The Major Rager

        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