I am trying to call a JavaScript function from codebehind which will show a modal. The JavaScript function is not getting called when using ScriptManager. Please help.
CodeBehind:
using System;
using System.Web.UI;
namespace test.web.controls
{
public partial class request_callback : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void open_callback_model()
{
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(),
"open_callback_modal", "javascript:open_callback_modal();", true);
}
}
}
JS:
<telerik:RadCodeBlock ID="rcb" runat="server">
<script type="text/javascript">
function open_callback_modal() {
alert('You clicked the button!')
$get("btn_open_callback").click();
}
</script>
</telerik:RadCodeBlock>
Calling open_callback_model() from a different control.
protected void btn_open_request_callback_Click(object sender, EventArgs e)
{
request_callback callback = new request_callback();
callback.open_callback_model();
}