Click here to Skip to main content
15,894,291 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to do buton invisible on amother button click using javascipt but getting error while debugging"object required"

//code

XML
<input type="submit" id="Submit" value="Submit" onclick="OpenWindow()" />
           <input type="submit" id="Update" value="Update" style="visibility:hidden" />
           <input type="submit" id="Edit" value="Edit" style="visibility:hidden" />


//javascript
C#
function OpenWindow() {
       debugger
       //alert("Student form window");
       //document.getElementById("Confirm").style.visibility = true;
       //document.getElementById("Update").style.visibility = true;
       // document.getElementById("Submit").style.visibility = false;

       var con = document.getElementById('<%=Confirm.ClientID%>');
       var update = document.getElementById('<%=Update.ClientID%');
       var edit = document.getElementById('<%=Edit.ClientID%');
       con.style.display = "none";
       update.style.display = "block";
       edit.style.display = "block";
      
       var dialog = $("#window-prototype").kendoWindow({
           width: "500px",
           height: "280px",
           modal: false,
           visible: true,
           resizable: true,
           actions: ["Custom", "Minimize", "Maximize", "Close"],
           title: "Student Form"

       }).show().data("kendoWindow").open().center();
Posted
Comments
Pheonyx 5-Feb-14 5:25am    
Where is the error occurring?
Hemant__Sharma 5-Feb-14 7:02am    
You should always specify exact location/line of error in your source code and scenario.

For example in above code I assume you are getting error on con.style because con would be undefined because document.getElementById('<%=Confirm.ClientID>'); wont return any element.

1 solution

when using mvc it does not require to use 'ClientID'.

try this
C#
var con=document.getElementById("#Submit");
 
Share this answer
 
v3
Comments
Hemant__Sharma 5-Feb-14 6:57am    
+5 accurate 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