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 button on one webform from other

disable button on one webform from other

Scheduled Pinned Locked Moved ASP.NET
announcement
5 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.
  • R Offline
    R Offline
    rocky811
    wrote on last edited by
    #1

    I have 2 webforms form1.aspx and form2.aspx. on form1 i have 2 buttons EDIT and NEW and on form2 i have SAVE and UPDATE .... I want to disable UPDATE button on form2 when i click NEW buttton on form1 and similarily i want to disable SAVE button when i click EDIT button in form1 . as EDIT buttton only should enable UPDATE and NEW should enable only SAVE please ..Its Urgent !!

    M 1 Reply Last reply
    0
    • R rocky811

      I have 2 webforms form1.aspx and form2.aspx. on form1 i have 2 buttons EDIT and NEW and on form2 i have SAVE and UPDATE .... I want to disable UPDATE button on form2 when i click NEW buttton on form1 and similarily i want to disable SAVE button when i click EDIT button in form1 . as EDIT buttton only should enable UPDATE and NEW should enable only SAVE please ..Its Urgent !!

      M Offline
      M Offline
      Michael Sync
      wrote on last edited by
      #2

      You should use the Session object or Cache to pass the information between the different forms. As your example, there is two buttons called "Edit" and "New" on WebForm1. If the user clicks the "New" button, you wanna enable the "Save" button and disable "Edit" button on WebForm2. then, write the following code in WebForm1 In btnNew_Click() event, Session["IsNew"] = true; In btnEdit_Click() event, Session["IsNew"] = false; In Page_Load() event of WebForm2 ~ btnSave.Enabled = Session["IsNew"]; btnUpdate.Enabled != Session["IsNew"]; Note: You should check whether the session is already exist or not.. If this session object is not exist then you will get the error.. Hope it helps..

      Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) "Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."

      R 1 Reply Last reply
      0
      • M Michael Sync

        You should use the Session object or Cache to pass the information between the different forms. As your example, there is two buttons called "Edit" and "New" on WebForm1. If the user clicks the "New" button, you wanna enable the "Save" button and disable "Edit" button on WebForm2. then, write the following code in WebForm1 In btnNew_Click() event, Session["IsNew"] = true; In btnEdit_Click() event, Session["IsNew"] = false; In Page_Load() event of WebForm2 ~ btnSave.Enabled = Session["IsNew"]; btnUpdate.Enabled != Session["IsNew"]; Note: You should check whether the session is already exist or not.. If this session object is not exist then you will get the error.. Hope it helps..

        Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) "Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."

        R Offline
        R Offline
        rocky811
        wrote on last edited by
        #3

        thanks for reply ..but i want both to happen i.e. if user clicks the "New" button, i wanna enable the "Save" button and disable "Update" button on WebForm2. and when user clicks EDIT button , i wanna enable Update button and disable Save button .. few errors i got for previous reply 1)Operator '!=' cannot be applied to operands of type 'bool' and 'object' 2)Cannot implicitly convert type 'object' to 'bool'. An explicit conversion exists (are you missing a cast?) 3)Only assignment, call, increment, decrement, and new object expressions can be used as a statement

        M 1 Reply Last reply
        0
        • R rocky811

          thanks for reply ..but i want both to happen i.e. if user clicks the "New" button, i wanna enable the "Save" button and disable "Update" button on WebForm2. and when user clicks EDIT button , i wanna enable Update button and disable Save button .. few errors i got for previous reply 1)Operator '!=' cannot be applied to operands of type 'bool' and 'object' 2)Cannot implicitly convert type 'object' to 'bool'. An explicit conversion exists (are you missing a cast?) 3)Only assignment, call, increment, decrement, and new object expressions can be used as a statement

          M Offline
          M Offline
          Michael Sync
          wrote on last edited by
          #4

          Please change like this below.. In Page_Load() event of WebForm2 ~ btnSave.Enabled = (bool)Session["IsNew"]; btnEdit.Enabled = !(bool)Session["IsNew"]; OR if (Session["IsNew"] == true){ btnSave.Enabled = true; btnEdit.Enabled = false; } else{ btnSave.Enabled = false; btnEdit.Enabled = true; }

          Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) "Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."

          R 1 Reply Last reply
          0
          • M Michael Sync

            Please change like this below.. In Page_Load() event of WebForm2 ~ btnSave.Enabled = (bool)Session["IsNew"]; btnEdit.Enabled = !(bool)Session["IsNew"]; OR if (Session["IsNew"] == true){ btnSave.Enabled = true; btnEdit.Enabled = false; } else{ btnSave.Enabled = false; btnEdit.Enabled = true; }

            Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) "Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."

            R Offline
            R Offline
            rocky811
            wrote on last edited by
            #5

            hey thanx a lot thats working !!!

            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