问题
I want to call this JQuery function from C# code behind but it is not work Here is the JQuery function
function showDialog(id, title) {
$(id).dialog({
modal: true, minWidth: 600, title: title
});
$(id).parent().appendTo($("form:first"));
}
and here is the code behind which i use
ClientScript.RegisterClientScriptBlock(this.GetType(), "myfunction", "$(document).ready(function(){showDialog('#editCustomer','نحديث معلومات عميل');});", true);
But it is not work
回答1:
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "myfunction", "<script type='text/javascript'>myFunction(params...);</script>", true);
回答2:
try this,
ScriptManager.RegisterClientScriptBlock(this.Page,this.GetType(), "myfunction", "$(document).ready(function(){showDialog('#editCustomer','نحديث معلومات عميل');});", true);
also try first putting your jQuery function inside $().
来源:https://stackoverflow.com/questions/19020303/call-a-jquery-function-from-code-behind-in-c-sharp