Domanda

I have 2 buttons which I want to hide by default on page load. On click of any row in the grid, I want these buttons to be visible. How can I hide the buttons using JQuery?

RadButton lnkAdd = new RadButton();
lnkAdd.ID = "BtnEdit";
lnkAdd.Text = "Edit";
container.Controls.Add(lnkAdd);

container.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "hideButtons",
    "\n<script type=\"text/javascript\">"
    //+ "\n$(function(){"           
    + "\n$(document).ready(function{"
    + "\n    $(\"#" + lnkAdd + "\").hide(); "                
    + "\n    return false;"
    + "\n  });"                
    + "\n</script>"
);

The following script is generated:

<SCRIPT type="text/javascript">
    $(document).ready(function ruchi(){
        $("#Telerik.Web.UI.RadButton").hide(); 
        return false;
    });
</SCRIPT>

But the buttons do not hide!

È stato utile?

Soluzione

Shouldn't it be + "\n $(\"#" + lnkAdd.ClientID + "\").hide(); " Right now it looks like you are just passing it the fully qualified name of the type and not the actual ID.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top