[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ValueChanged event for HiddenField not firing for some reason.

Posted on 2007-10-10
9
Medium Priority
?
2,918 Views
Last Modified: 2008-03-01
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.
0
Comment
Question by:ameert
  • 4
  • 3
8 Comments
 
LVL 20

Expert Comment

by:Gawai
ID: 20051210
what if you change protected to public ?

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

Expert Comment

by:Gawai
ID: 20051281
or sure javascript instead

<script lanugage=javascript runat=server>

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

</script>

0
 

Author Comment

by:ameert
ID: 20051287
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:ameert
ID: 20051301
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
 
LVL 20

Expert Comment

by:Gawai
ID: 20051341
might you have missed some lines of code in popup window page.
0
 

Author Comment

by:ameert
ID: 20052765
Does anyone have a solution to this? I really need to get this done.
0
 

Author Comment

by:ameert
ID: 20057407
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
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 21022582
PAQed with points refunded (200)

Computer101
EE Admin
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Suggested Courses
Course of the Month19 days, 10 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question