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

I have written code for link button disabled which is dynamically generated in the javascript.this code works properly in IE but not in other browser.Also Some code works properly in chrome but not in IE.I have used hidden variable in which list of all button(hdnModeList) store and in another varible btn which clicked store(hdnMode).my code is given as
C#
function PageLoad() {  
        btnList = document.getElementById('hdnModeList').value;
        EnableDisableAllCtrls(true);
        if (document.getElementById('hdnMode').value != "") {
            setMode(document.getElementById('hdnMode').value);
        }
        if (document.getElementById('hdnSuccessMessage').value == "Success") {            
            alert(document.getElementById('hdnUserSuccessMessage').value);
            Clear_Page();
            document.getElementById('hdnUserSuccessMessage').value = "";
            document.getElementById('hdnSuccessMessage').value = "";
        }
    }
// setMode - Obtains the value of clicked button to get Mode

function setMode(mode) {
   // PageMethods.EnableDisabledMenu();
    document.getElementById('hdnMode').value = mode;  
    var splitRes = document.getElementById('hdnModeList').value.split(",");    
//======== this is code where i am disabling all btn other than click one =========

     for (var i = 0; i < splitRes.length; i++) {
         if ((splitRes[i] != "") && (splitRes[i].substring(3) != mode)) {             
             document.getElementById(splitRes[i]).disabled = true;           
         }
     }    
    var C ;
 // ================= this value "mode" assign to var c not assign in ie browser but works in chrome=====================  
 C = mode;
    
    if (C== 'View') {
         document.getElementById('btnConfirm').disabled = true;
     }

     SetEnableDisable(C);
 }
 function SetEnableDisable(getId) {
    alert('getId='+getId);
     var retval = true;
     if (getId == "Add") { 
         retval = OnAddClick();
     }
     else if (getId == "Modify") {
         retval = OnModifyClick();
     }
     else if (getId == "Delete") {
         retval = OnDeleteClick();
     }
     else if (getId == "View") {
         retval = OnViewClick();
     }
     else if (getId == "Approve") {
         retval = OnApproveClick();
     }
     else if (getId == "DeActivate") {
         retval = OnDeActivateClick();
     }
     else if (getId == "ReActivate") {
         retval = OnReActivateClick();
     }
     else if (getId == "Cancel") {
         retval = OnCancelClick();
     }
     else if (getId == "Execute") {
         retval = OnExecuteClick();
     }
     else if (getId == "Print") {
         retval = OnPrintClick();
     }
     else if (getId == "Review") {
         retval = OnReviewClick();
     }
     else if (getId == "Release") {
         retval = OnRelease();
     }
     if (retval == true) {
         return true;
     }
     else {
         return false;
     }
 }

this PageLoadfunctn call on master page load and setmode call in PageLoad as well as onclick event of btn.
Provide a soln to work this in all browser.if is there any error in the code inform me.thanx

provide soln
Posted
Updated 7-Jun-12 20:28pm
v2
Comments
Arunprasath Natarajan 10-Jun-12 2:44am    
If it work in IE and Not in other browser, This problem may occur due to naming the fields and naming its ID.
Ensure name and ID of the fields must be same.
Martin Arapovic 20-Jun-12 8:54am    
Hi, I just want to add a comment/suggestion. For things like this in your question i suggest you to use some js framework/library, like jQuery, prototype, mootools. Using them to select and manipulate DOM elements on page, your code will work in all browsers, because they are taking care of the browser and its version...

1 solution

Please check the browser support list of properties that you have used.
Bcz some browsers not supported all the properties.

Thanks
Nikhil
 
Share this answer
 

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


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