Hi @ANB , from your description of this question, I think you want to use DOM.Click()
instead of calling the onclick method directly in OnAfterRenderAsync()
method. Please refer to this simple demo.
Create a js file called MyScript.js
in wwwroot
:
var BlazorTest = BlazorTest || {};
BlazorTest.setClick = function (element) {
element.click();
};
refer this js file in index.cshtml
Then in your Razor Component
Demo:
-------------------------------------------------------------------------------------------
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Brian Shen