2

I'm working on an existing code and came across a ASP button which has a onClick and onClientClick event on it.

I'm trying to generate a click event from an external Javascript file so that both the events are triggered.

I'm using the below line to achive it-

document.getElementById("ID_ReleaseUserAuthPending_okBtn").click();

But the OnClientClick event is being triggered as expected, but the onClick event isn't. i.e., The Javascript method is being processed, but the onClick() in the C# codebehind isn't.

Please help me out if there is any way where I can call the onClick event too.

Thanks in advance.

theLearner
  • 363
  • 4
  • 16

2 Answers2

1

From the client click function, from js, call __dopostback. That is underscore underscore do post back. You can google it for sample code. https://www.codeproject.com/articles/667531/dopostback-function

Amit Kumar Singh
  • 4,393
  • 2
  • 9
  • 22
0

At the end of javascript method put

return true;

statement.

It should work.

  • It is returned as true @abhishek . The code works fine when directly clicked on the button. The issue is faced when triggered from JS – theLearner Jul 13 '17 at 10:19