Click here to Skip to main content
13,050,242 members (100,227 online)
Rate this:
Please Sign up or sign in to vote.
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 ....
Posted 27-Dec-12 20:03pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100