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. How to clear data from All textbox in a form

How to clear data from All textbox in a form

Scheduled Pinned Locked Moved ASP.NET
helptutorial
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.
  • D Offline
    D Offline
    dj rock
    wrote on last edited by
    #1

    Hi guys i am developing one website and it is having mane forms. and all those forms have many textboxes. so after inserting data from textbox i want to make all text box clear. for that i dont want to write each and every textbox.text="" so if any one knows other solution please help :(:(

    Regards, DJ Rock

    L 1 Reply Last reply
    0
    • D dj rock

      Hi guys i am developing one website and it is having mane forms. and all those forms have many textboxes. so after inserting data from textbox i want to make all text box clear. for that i dont want to write each and every textbox.text="" so if any one knows other solution please help :(:(

      Regards, DJ Rock

      L Offline
      L Offline
      l0kke
      wrote on last edited by
      #2

      I'm not sure, but I think you should play around with viewstate. You can set EnableViewState property of your textboxes to false, or you can set this property to be false for whole page, if you don't need viewstate at all. Or you can override LoadViewState or SaveViewState methods of your Page class. Or you can simply go through all controls and if a control is type of TextBox set its text to "" foreach(System.Web.UI.Control control in Page.Controls) { SetTextBoxesText(control); } public void SetTextBoxesText(System.Web.UI.Control control) { if (control.GetType() == "System.Web.UI.WebControls.TextBox") { ((System.Web.UI.WebControls.TextBox)control).Text = ""; } foreach (System.Web.UI.Control childControl in control.Controls) { SetTextBoxesText(childControl); } } Pilo

      D 1 Reply Last reply
      0
      • L l0kke

        I'm not sure, but I think you should play around with viewstate. You can set EnableViewState property of your textboxes to false, or you can set this property to be false for whole page, if you don't need viewstate at all. Or you can override LoadViewState or SaveViewState methods of your Page class. Or you can simply go through all controls and if a control is type of TextBox set its text to "" foreach(System.Web.UI.Control control in Page.Controls) { SetTextBoxesText(control); } public void SetTextBoxesText(System.Web.UI.Control control) { if (control.GetType() == "System.Web.UI.WebControls.TextBox") { ((System.Web.UI.WebControls.TextBox)control).Text = ""; } foreach (System.Web.UI.Control childControl in control.Controls) { SetTextBoxesText(childControl); } } Pilo

        D Offline
        D Offline
        dj rock
        wrote on last edited by
        #3

        thanks for your reply :):):)

        Regards, DJ Rock

        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