Click here to Skip to main content
15,943,419 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,

i have a problem with jquery..
i need to make controls disabled based on some conditions..
that i have done using jquery and cssclass..
but the problem is that those disabled controls gets enabled when postback occurs..
i have tried registering the script at pageload pageload complete events...but for the first time function is being called but if postback occurs that javascript function not gets called...plz help me if i am doing anything wrong..

here is my javascript function..

function DisableControls() {
       //disabling all controls
       $("form :input").attr("disabled", "disabled");
       //enabling controls with css class 'EnableConrols'
       var $ControlsToEnabled = $(':input.EnableConrols');
       var count = 0;
       var length = $ControlsToEnabled.length;
       while (count < length) {
           var Control = $ControlsToEnabled[count];
           Control.disabled = false;

.cs file
public partial class RmsViewWorkSheetDetails : securedPage
        protected void Page_Load(object sender, EventArgs e)
         ClientScript.RegisterStartupScript(Page.GetType(), "OnLoad",                                                          "DisableControls();", true); 
         this.LoadComplete += new System.EventHandler(this.Page_LoadComplete);
       new private void Page_LoadComplete(object sender, System.EventArgs e)
           base.Page_LoadComplete(sender, e);
           ClientScript.RegisterStartupScript(Page.GetType(), "OnLoad", "DisableControls();", true); 


after postback DisableControls() function not gets fired...
plz help me ....

thanks ....

1 solution

Have you looked at the source code that is returned to see if the method is emitted ? Have you used a breakpoint to see if your method is called in the code behind ? Have you debugged in chrome to set a break point and see if this is called ?

This[^] is the method in which your call should take place, so it's called after your page is loaded.
Share this answer

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