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. Other Discussions
  3. The Weird and The Wonderful
  4. great way to clear asp.net form fields

great way to clear asp.net form fields

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpasp-net
1 Posts 1 Posters 1 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.
  • F Offline
    F Offline
    freddy rios
    wrote on last edited by
    #1

    I am updating an asp.net application developed by someone else to use master pages, and I was getting a NullReferenceException with the following lines:

    Line 61: }
    Line 62: if (IsRequiredField('<%= txtExpDate.ClientID %>', 'Expiry Date', errorLbl) == false)
    Line 63: if (f.value==1)

    After some time to figure out what was happening, I found this perfect way to clear asp.net controls :((:

    private void ClearFields()
    {
    this.txtCouponCode.Text="";
    this.txtCouponName.Text="";
    this.txtDiscount.Text="";
    this.txtNoUses.Text="";
    this.ddlNoUses.SelectedIndex=1;
    this.txtExpDate=null; // WTF!!!!!!
    }

    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