?
Solved

Enable Disable on button doesn't stay

Posted on 2011-10-23
3
Medium Priority
?
281 Views
Last Modified: 2012-08-13

I have an asp.net button where it's enabled property is set to false.
I then have a javascript function that is called when a user makes a change to a field.
In this function it sets the button to disabled = false.
That all works, but within a few seconds the button returns to it's enabled state set on the button.
How can I make this stay?
Thanks
<asp:Button ID="buttContactSave"  runat="server" CssClass="button" Enabled="false" OnClientClick="javascript:cleardirty('ctl00_ContentPlaceHolder1_HiConInfoDirty', this)" OnClick="buttContactSave_Click" Text="Save" TabIndex="10" />

###text field that sends to functions that sets disabled

 <asp:TextBox ID="txtFirstName" runat="server" onchange="javascript:setdirty('ctl00_ContentPlaceHolder1_HiConInfoDirty','ctl00_ContentPlaceHolder1_wzdSetup_buttContactSave');"MaxLength="50" CssClass="backyellow" EnableViewState="true" AutoPostBack="true" ></asp:TextBox>

### javascript

   function setdirty(hifield, buttsave) {
    var hi = document.getElementById(hifield);
    hi.value = "true";
    var hipage = document.getElementById("ctl00_ContentPlaceHolder1_HiPageDirty");
    hipage.value = "true";
    var butt = document.getElementById(buttsave);
    butt.disabled = false;
 }

   function setdirty(hifield, buttsave) {
    var hi = document.getElementById(hifield);
    hi.value = "true";
    var hipage = document.getElementById("ctl00_ContentPlaceHolder1_HiPageDirty");
    hipage.value = "true";
    var butt = document.getElementById(buttsave);
    butt.disabled = false;
 }

Open in new window

0
Comment
Question by:Sheritlw
3 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 680 total points
ID: 37015906
Impossible to say without loading the page. Sounds to my non-asp ears that the page gets reloaded by a postback
0
 
LVL 18

Assisted Solution

by:mgfranz
mgfranz earned 660 total points
ID: 37016021
Well, first of all, try changing certain states one at a time.

EnableViewState="false" AutoPostBack="false"
0
 
LVL 28

Assisted Solution

by:strickdd
strickdd earned 660 total points
ID: 37018606
Please post the entire page code if possible. I agree with @mplungjan, it is most likely a postback causing this issue.

I would recommend checking with Firebug to see if a request is being made before the button changes back.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question