Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0
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() {
       debugger;
       //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;
           count++;
       }
   }
 
.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 21:03pm

1 solution

Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 Afzaal Ahmad Zeeshan 256
1 OriginalGriff 251
2 BillWoodruff 240
3 Maciej Los 230
4 Sergey Alexandrovich Kryukov 195
0 OriginalGriff 6,419
1 Sergey Alexandrovich Kryukov 6,008
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,070


Advertise | Privacy | Mobile
Web01 | 2.8.1411019.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2014
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