disable button on one webform from other
-
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 !!
-
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 !!
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."
-
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."
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
-
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
Please change like this below.. In Page_Load() event of WebForm2 ~
btnSave.Enabled = (bool)Session["IsNew"]; btnEdit.Enabled = !(bool)Session["IsNew"];
ORif (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."
-
Please change like this below.. In Page_Load() event of WebForm2 ~
btnSave.Enabled = (bool)Session["IsNew"]; btnEdit.Enabled = !(bool)Session["IsNew"];
ORif (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."