asp.net - What does aspnet keep overwritting my onclick attribute? -


i have button on form. during page_load event add new onclick attribute button via code behind. when inspect button in firefox attribute not there , being replaced with:

onclick='javascript:webform_dopostbackwithoptions(new webform_postbackoptions("button_modal_search", "", true, "modalsearch", "", false, false))'

here tag before run app:

here's code behind: button_modal_search.attributes.add("onclick", "return showsearchspinner()")

anyone know how can prevent attribute being overwritten?

asp.net indeed overrides onclick attribute, provide onclientclick property allow specify own client-side behavior:

button_modal_search.onclientclick = "return showsearchspinner();" 

if value of property constant, can specify attribute in button markup itself.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -