Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I have input control whose type is hidden.

Please refer the below html.

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


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.
Posted
Updated 17-Mar-15 19:44pm
v2

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.
 
Share this answer
 
If you want to use server-events you'll need to use the asp:HiddenField server control.

XML
<script type="text/javascript">
    $(document).ready(function () {
        $("#hdnEasyPLarID").val("world");
    });
</script>

<form id="form1" runat="server">

<asp:HiddenField ID="hdnEasyPLarID" runat="server" OnValueChanged="hdnEasyPLarID_ValueChanged" Value="Hello" />
<asp:Button ID="ButtonSubmit" Text="Submit" runat="server" />

</form>


code behind

C#
protected void hdnEasyPLarID_ValueChanged(object sender, EventArgs e)
{
    string value = hdnEasyPLarID.Value;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900