Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
i have the following codes

C#
protected void Page_Load(object sender, EventArgs e)
       {
           if (!IsPostBack)
           {
               txtFName.Enabled = false; txtMName.Enabled = false; txtLName.Enabled = false; txtUNic.Enabled = false; txtUDob.Enabled = false;
              
btnSave.Enabled = false; btnDelete.Enabled = false;
           }
       }

       protected void btnAdd_Click(object sender, EventArgs e)
       {
           txtFName.Enabled = true; txtMName.Enabled = true; txtLName.Enabled = true; txtUNic.Enabled = true; txtUDob.Enabled = true;

btnSave.Enabled = true; btnDelete.Enabled = false; btnShow.Enabled = false; btnAdd.Enabled = false;
           //txtFName.Attributes.Remove("readonly");
           txtFName.Focus();


       }


i want to make my save button enable and disable all other when click on add button but it seems that it just refresh the page. but the trick with text boxes is working.

Note: textbox and button are in the contentpage which is displayed in contentplaceholder.
Posted

1 solution

Hi I think u need learn Asp Page Life cycle.

In btnAdd click event u write btnSave button enable as true,but in page not post back event u again btnSave button enable as false ? why ?

Finally what u get when page open btnSave button is enabled,when u click btnAdd then btnSave button will disabled,bcz u disable save button in page not post back event.


I think ur need is ,when page open need to disable save button and textbox,when click add button need to enable save button and textbox,if yes means,in postback event u add save button and textbox disable code and in not postback event u add save button and textbox enable code


and try update panel for not refresh page

https://msdn.microsoft.com/en-us/library/bb399001.aspx[^]
https://msdn.microsoft.com/en-us/library/bb386454.aspx[^]

Put ur control inside update panel,then only controls update ,i mean button enable and disable without page refersh
 
Share this answer
 
v7

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900