如何触发隐藏输入类型的onchange事件

如何触发隐藏输入类型的onchange事件

问题描述:

大家好,



我的输入控件的类型是隐藏的。



请参考在html下面。



Hi All,

I have input control whose type is hidden.

Please refer the below html.

<input id="hdnEasyPLarID" type="hidden" class="hdnEasyPLarIDClass" runat="server" ="EasyP_ID_Changed();" />





隐藏输入的值可以通过代码隐藏(c#)或使用脚本以编程方式更改。



但是当值改变时,onchange事件不会触发。



请告诉我如何继续。



先谢谢。



The value of hidden input is changed programmatically either by code behind(c#) or by using script.

But the onchange event is not firing when the value is changed.

Kindly advise me how to proceed.

Thanks in Advance.

onchange事件是一个用户事件。如果你通过脚本更改值,它将不会触发。



当被后面的代码更改时,它肯定不会触发。因为它是一个客户事件。页面从后面的代码返回后会发生绑定。



也许你应该澄清你想要完成的事情。
The onchange event is a user event. It will not fire if you change the value by script.

It will certainly not fire when changed by the code behind. Since it is a client event. The binding of it will happen after the page has returned from the code behind.

Perhaps you should clarify what you are trying to accomplish.

>

如果你想使用服务器事件,你需要使用asp:HiddenField服务器控件。



If you want to use server-events you'll need to use the asp:HiddenField server control.

<script type="text/javascript">


(document).ready(function(){
(document).ready(function () {