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. Disable all textbox & window.open problem

Disable all textbox & window.open problem

Scheduled Pinned Locked Moved ASP.NET
sysadminhelpquestion
6 Posts 3 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.
  • J Offline
    J Offline
    J Liang
    wrote on last edited by
    #1

    Hi, I have two problems here. 1. When I open a page, when some criterias met, I want all the textbox, drop down box etc to be disable. I know I can disable them one by one but there are just too many of them and I have 10 similiar page, so I was wondering whether is there anyway that I can use a few line of codes to disable all of them. 2. I am using server side window.open as below public void Window_Open(string url, bool resize, int height, int width, int scrollbar) { System.Web.HttpContext.Current.Response.Write(""); System.Web.HttpContext.Current.Response.Write("window.open('" + url + "','','resize=" + resize + ",height=" + height + ",width=" + width + ",scrollbar=" + scrollbar + "');"); } Which works well but when it will refresh my parent page and cause all my fonts to become larger. I need to hide the link button which call Window_Open(...), so I have to put it as server side control so it only appear when some criterias are met. So is there anyway I can stop the page from refreshing from the server side? Thanks in advance. J Liang

    R A 2 Replies Last reply
    0
    • J J Liang

      Hi, I have two problems here. 1. When I open a page, when some criterias met, I want all the textbox, drop down box etc to be disable. I know I can disable them one by one but there are just too many of them and I have 10 similiar page, so I was wondering whether is there anyway that I can use a few line of codes to disable all of them. 2. I am using server side window.open as below public void Window_Open(string url, bool resize, int height, int width, int scrollbar) { System.Web.HttpContext.Current.Response.Write(""); System.Web.HttpContext.Current.Response.Write("window.open('" + url + "','','resize=" + resize + ",height=" + height + ",width=" + width + ",scrollbar=" + scrollbar + "');"); } Which works well but when it will refresh my parent page and cause all my fonts to become larger. I need to hide the link button which call Window_Open(...), so I have to put it as server side control so it only appear when some criterias are met. So is there anyway I can stop the page from refreshing from the server side? Thanks in advance. J Liang

      R Offline
      R Offline
      Red_Wizard_Shot_The_Food
      wrote on last edited by
      #2

      1: Place the controls you want disabling inside a panel and disable the panel. Cheers,

      J 1 Reply Last reply
      0
      • J J Liang

        Hi, I have two problems here. 1. When I open a page, when some criterias met, I want all the textbox, drop down box etc to be disable. I know I can disable them one by one but there are just too many of them and I have 10 similiar page, so I was wondering whether is there anyway that I can use a few line of codes to disable all of them. 2. I am using server side window.open as below public void Window_Open(string url, bool resize, int height, int width, int scrollbar) { System.Web.HttpContext.Current.Response.Write(""); System.Web.HttpContext.Current.Response.Write("window.open('" + url + "','','resize=" + resize + ",height=" + height + ",width=" + width + ",scrollbar=" + scrollbar + "');"); } Which works well but when it will refresh my parent page and cause all my fonts to become larger. I need to hide the link button which call Window_Open(...), so I have to put it as server side control so it only appear when some criterias are met. So is there anyway I can stop the page from refreshing from the server side? Thanks in advance. J Liang

        A Offline
        A Offline
        Arindam Tewary
        wrote on last edited by
        #3

        J Liang 1. At the end of your page having HTML ... use some javascipt following way ... Exaple: getElementsByTagName("input") returns all input HTML control in your rendered page. Now iterate in a loop to set the "disabled" property as you want. var arr = document.getElementByTagName("input") for(int i=0;i<arr.length;i++) { if(arr[i].type='text') { arr[i].disabled = true } if(arr[i].type='button') { arr[i].disabled = true } //like this } 2. Is there any explicit reason that you are opening a new window from the server side.Generally there is no reason to open a window from server side

        Thanks, Arindam D Tewary

        J 1 Reply Last reply
        0
        • R Red_Wizard_Shot_The_Food

          1: Place the controls you want disabling inside a panel and disable the panel. Cheers,

          J Offline
          J Offline
          J Liang
          wrote on last edited by
          #4

          Hi, Disabling the panel might not be a good idea for me as it will grey-out the entire interface and make it harder for the user to read. Further more, there is something else I need to leave it active such as a button. Any idea other than using panel? Thanks in advance. J Liang

          R 1 Reply Last reply
          0
          • A Arindam Tewary

            J Liang 1. At the end of your page having HTML ... use some javascipt following way ... Exaple: getElementsByTagName("input") returns all input HTML control in your rendered page. Now iterate in a loop to set the "disabled" property as you want. var arr = document.getElementByTagName("input") for(int i=0;i<arr.length;i++) { if(arr[i].type='text') { arr[i].disabled = true } if(arr[i].type='button') { arr[i].disabled = true } //like this } 2. Is there any explicit reason that you are opening a new window from the server side.Generally there is no reason to open a window from server side

            Thanks, Arindam D Tewary

            J Offline
            J Offline
            J Liang
            wrote on last edited by
            #5

            Hi, 1. I could not use javascript, unless from asp.net, it can use that piece of javascript you posted here as the javascript only allowed to run if some of the criterias are meet where the checking is done using asp.net. 2. The reason I set the link to open a new window as server side control is because I need to hide it and only make it available when some criterias are met. Again, the checking is done from asp.net. Any idea which I can solely do all these things using asp.net? Thanks in advance J Liang

            1 Reply Last reply
            0
            • J J Liang

              Hi, Disabling the panel might not be a good idea for me as it will grey-out the entire interface and make it harder for the user to read. Further more, there is something else I need to leave it active such as a button. Any idea other than using panel? Thanks in advance. J Liang

              R Offline
              R Offline
              Red_Wizard_Shot_The_Food
              wrote on last edited by
              #6

              Just don't place the button on the panel... OR: Name all your text boxes so they start with "textbox" "txtb" or "tb" etc etc (its a good idea to name controls like this anyway). foreach (Control c in myPanel) { if(c.ID.StartsWith("textbox")) { ((TextBox)c).ReadOnly = true; } }

              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