I have a server control page where the input is entered and when button is clicked I want to trigger function in .aspx and again continue the C# code written below the script manager.
Now the thing is that I used ScriptManager.RegisterStartupScript(this, GetType(), "", "trackButtonClick()", true);
and even I used ClientScript
for checking but still the function is not being called or run written in .aspx
The below codes after ScriptManager.RegisterStartupScript(this, GetType(), "", "trackButtonClick()", true);
run smoothly but not the JS function declared in .aspx
I have no AJAX POST calls or any other. The page is completely server side control
I tried every solution can anyone check and say what is the issue here as nothing displays in console or anywhere?
Can anyone Help?
protected void btnPay_Click(object sender, EventArgs e)
{
// other codes
ScriptManager.RegisterStartupScript(this, GetType(), "", "trackButtonClick()", true);
// other codes
}
This is the .aspx
<script type="text/javascript">
function trackButtonClick() {
console.log('trackButtonClick function executed');
}
</script>
its solved. Instead of "this" in code I just put an address of button i.e btnPay Hence the code looked like this
ScriptManager.RegisterStartupScript(btnPay , GetType(), "", "trackButtonClick()", true);