I have read many reference for this question but not getting result. So, I thought let me try to explain my scienario here.
This is my 3 script which is in view.ascx
control. I want to call it in .cs
file function and in click event.
view.ascx
<script type="text/javascript">
function startLoading() {
alert("load start");
var el = jQuery(".scp-entry-header");
App.blockUI(el);
}
function stopLoading() {
alert("load end");
var el = jQuery(".scp-entry-header");
App.unblockUI(el);
}
function getCalendarData() {
alert("calendarcalled");
}
</script>
view.ascx.cs
//ViewData button click
protected void btnGetData_Click(object sender, EventArgs e)
{
//How to call startLoading function here?
process from database;
//How to call stopLoading function here?
}
//simple function call
protected void showCalendar()
{
//How to call getCalendarData function here?
}
I have read about RegisterScript but not getting result. I don't understand where to RegisterScript and how to call it in function.
Can anybody please suggest me in detail how can I call javascript function here?
Try This
protected void btnGetData_Click(object sender, EventArgs e)
{
//How to call startLoading function here?
process from database;
//How to call stopLoading function here?
Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "startLoading", true);
}
or
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", "<script>alert('Hello.')</script>", false);