How to Use Java script on Ajax

Posted by rameshch on July 10, 2008

My button is in user control and i want to hide the button on page based on the differnts events.

it can be solved by the like this

on user control we need to write the function as

function 

DisableButton() {

document.getElementById(

‘<%=btnShow.ClientID %>’).disabled=true ;} 

function EnableButton() {document.getElementById(‘<%=btnShow.ClientID %>’).disabled=false ;  }

 

 

 

 

function  HideReportToExcel() { document.getElementById(‘<%=btnReportToExcel.ClientID %>’).style.visibility = “hidden” ; }
function ShowReportToExcel() {

document.getElementById( ‘<%=btnReportToExcel.ClientID %>’).style.visibility = “visible”  ;  }

on button we have to mention the style has 

 

 

<asp:Button ID=”btnReportToExcel” runat=”server” Text=”Report To Excel” ValidationGroup=”submit” style=”visibility:hidden; />

 another way

function ShowReportToExcel() {
document.getElementById( ‘<%=btnReportToExcel.ClientID %>’).Add.style(display, ’ ‘)  ;  }

 function HideReportToExcel() {
document.getElementById( ‘<%=btnReportToExcel.ClientID %>’).Add.style(display, ’none ‘)  ;  }

 <asp:Button ID=”btnReportToExcel” runat=”server” Text=”Report To Excel” ValidationGroup=”submit” style=”display:none;” OnClick=”OnClick_ReportTOExcel”/>   

 

<asp:Button ID=”btnReportToExcel” runat=”server” Text=”Report To Excel” ValidationGroup=”submit” style=”display:none;” OnClick=”OnClick_ReportTOExcel”/>

 

  on the code behind  call this

 string script = “if(document.getElementById(‘” + pnlConsumption.ClientID + “‘) != null) { document.getElementById(‘”+ pnlConsumption.ClientID + “‘).style.display=’none’; HideReportToExcel();}”

ScriptManager.RegisterStartupScript(Page, GetType(), “hidegrid”, script, true);

Leave a Reply

You must be logged in to post a comment.