ValueChanged event for HiddenField not firing for some reason.

I have an aspx page with a label and a hidden field. Through javascript, I set the value of the hidden field, and then call __doPostBack. But the valuechanged event doesn't fire. Is this correct what I have below (I believe it is). My aspx page has a master page and everything within my aspx paage is all inside content tags.

<script language=javascript>
            function ConfigureDialog()
            {
                var ea = "<%= Request.Form["__EVENTARGUMENT"]  %>";
                if (ea != "HdnFldSet")
                {
                      var ttt = "val1";
                      var oRouteType = document.getElementById("<%= HiddenField6.ClientID %>");
                      oRouteType.Value = ttt;
                          __doPostBack("HiddenField6",'HdnFldSet'); //i even tried "<%= HiddenField6.ClientID %>" in place of "HiddenField6" here
                     }
              }
</script>
    <asp:HiddenField ID="HiddenField6" runat="server" OnValueChanged="HiddenField6_ValueChanged" />

     <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></p>
<script>
     ConfigureDialog();
</script>


Then on code behind page:

        protected void HiddenField6_ValueChanged(object sender, EventArgs e)
        {
            Label1.Text = "someText...never shows for some reason.";
        }

By the way I have page EnableEventValidation set to false. I open this page as a popup from another page.
Please tell me if there is anything wrong with this code....the valueChanged event never fires and I can't understand why.
ameertAsked:
Who is Participating?
 
Computer101Connect With a Mentor Commented:
PAQed with points refunded (200)

Computer101
EE Admin
0
 
GawaiCommented:
what if you change protected to public ?

public void HiddenField6_ValueChanged(object sender, EventArgs e)
        {
            Label1.Text = "someText...never shows for some reason.";
        }
0
 
GawaiCommented:
or sure javascript instead

<script lanugage=javascript runat=server>

function onHiddenFieldchange(){
 document.getElementById("Label1").value = "changed text shown";
}

</script>

0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
ameertAuthor Commented:
Hello gawai, no luck with that either.

Strange this this works fine from a parent window....but then in the popup window it's not working and it's the exact same code.
0
 
ameertAuthor Commented:
i can't use the second option because in the c# event I have, I need to set some properties to a datagrid depending on what value was assigned to the hiddenfield
0
 
GawaiCommented:
might you have missed some lines of code in popup window page.
0
 
ameertAuthor Commented:
Does anyone have a solution to this? I really need to get this done.
0
 
ameertAuthor Commented:
Ok, figured it out.....I'm posting this soln in case anyone else has a similar problem.

I added the following to Render event and I turned on EnableEventValidation:

Page.ClientScript.RegisterForEventValidation(this.HiddenField6.UniqueID, "");

I also changed <%= HiddenField6.ClientID %> to <%= HiddenField6.UniqueID %>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.