ScriptManager.RegisterClientScriptBlock pratices
-
Hello, I have a Javascript function that needs to be thrown several times in the code-behind(C#) for user navigation. I wanna know if calling the function by the method ScriptManager.RegisterClientScriptBlock is a good practice to resolve this issue. Thanks.
-
Hello, I have a Javascript function that needs to be thrown several times in the code-behind(C#) for user navigation. I wanna know if calling the function by the method ScriptManager.RegisterClientScriptBlock is a good practice to resolve this issue. Thanks.
-
Hello, I have a Javascript function that needs to be thrown several times in the code-behind(C#) for user navigation. I wanna know if calling the function by the method ScriptManager.RegisterClientScriptBlock is a good practice to resolve this issue. Thanks.
brunoseixas wrote:
a Javascript function that needs to be thrown several times in the code-behind(C#)
You can't call a JavaScript function from code-behind. You can however write the JavaScript to the output stream. The best way would be to execute the script from the client-side load event such as
or with JQuery
$(document).ready( function() { MyFunction(); });
I know the language. I've read a book. - _Madmatt
-
brunoseixas wrote:
a Javascript function that needs to be thrown several times in the code-behind(C#)
You can't call a JavaScript function from code-behind. You can however write the JavaScript to the output stream. The best way would be to execute the script from the client-side load event such as
or with JQuery
$(document).ready( function() { MyFunction(); });
I know the language. I've read a book. - _Madmatt
Yes, there is a reason. This page uses a free javascript code called niceforms (http://www.emblematiq.com/lab/niceforms/), it has several bugs and needs to be recharged several times. And the problem is that it does not reload correctly if called at events such as onLoad or EndRequest in html (I do not know why). So, I created a static method in BasePage application that contains a method that performs this function across the ScriptManager. The solution I found was this, and I'm just calling it in Page_Load when is postback. Thank you.
-
Yes, there is a reason. This page uses a free javascript code called niceforms (http://www.emblematiq.com/lab/niceforms/), it has several bugs and needs to be recharged several times. And the problem is that it does not reload correctly if called at events such as onLoad or EndRequest in html (I do not know why). So, I created a static method in BasePage application that contains a method that performs this function across the ScriptManager. The solution I found was this, and I'm just calling it in Page_Load when is postback. Thank you.
brunoseixas wrote:
The solution I found was this...
No the solution is to use code that isn't buggy and functions appropriately.
I know the language. I've read a book. - _Madmatt
-
brunoseixas wrote:
The solution I found was this...
No the solution is to use code that isn't buggy and functions appropriately.
I know the language. I've read a book. - _Madmatt
Yes, of course. Tell that to the dummies of the commercial area. Haaaa :laugh: