I am trying to add some jquery to span with a class added to it. I am using asp.net and trying to use RegisterClientScriptBlock to attach the below code to my element. "cphMain_ed1" is hardcoded in this example however I would normally been passing a parameter here just for the ease of this.
<script language="javascript" type="text/javascript">
$(function () {
$('.closeButton').click(function () {
alert('called ok');
$("cphMain_ed1").slideUp();
});
});
</script>
My c# code looks like this
String csName = string.Format("ButtonClickScript_{0}", this.ID);
Type csType = this.GetType();
////// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;
StringBuilder csText = new StringBuilder();
// csText.Append("<script type=\"text/javascript\"> HidePanel('" + this.ID + "')");
csText.Append("<script type=\"text/javascript\">DoIt()");
csText.Append("</script>");
cs.RegisterClientScriptBlock(csType, csName, csText.ToString());
What am I doing wrong as the function is not been attached to the span with the class "closeButton"
ANy help would be great!!