Set hidden value from JS codebhind not working?

  1. #1

    Set hidden value from JS codebhind not working?

    I am trying to set a hidden value from code behind JS... Using it as I am trying to get the a value fron a control in an iFrame parent - when I run the below - everything fires but the hdnProCheck in the last lines value is not showing?

    
    
    
    this.ScriptManager1.AddScript("alert(parent.rb1.checked);if (parent.rb1.checked){hdnProCheck.setValue('1')};alert(hdnProCheck.getValue());");
    
    
    int result;
    
    
    result = String.Compare(hdnProCheck.Value.ToString(), "1");
    
    
    this.ScriptManager1.AddScript("alert('" + hdnProCheck.Value.ToString() + "');");
  2. #2

    RE: Set hidden value from JS codebhind not working?

    Hi Tbaseflug,

    Your code appears fine at first glance.


    Can you post a simplified .aspx sample demonstrating the full scenario.


    Geoffrey McGill
    Founder
  3. #3

    RE: Set hidden value from JS codebhind not working?

    Sure - it is just really strange - I kept it simple here and still when I try the second alert from the code-behind... nothing

    here is the aspx:
    
    
    
    <body>
    
    
    <form id="form1" runat="server">
    
    
    <ext:ScriptManager ID="ScriptManager1" runat="server">
    
    
    </ext:ScriptManager>
    
    
    
    
    
    <ext:Hidden runat="server" ID="hdnProCheck" />
    
    
    
    
    
    
    </form>
    
    
    </body>
    and here is the simple code-behind
    
    
    
    
    protected void Page_Load(object sender, EventArgs e)
    
    
    {
    
    
    this.ScriptManager1.AddScript(hdnProCheck.ClientID + ".setValue('1');alert(" + hdnProCheck.ClientID + ".getValue());");
    
    
    this.ScriptManager1.AddScript("alert('" + hdnProCheck.Value + "');");
    
    
    }
  4. #4

    RE: Set hidden value from JS codebhind not working?

    so - in summary - this works:



    this.ScriptManager1.AddScript("alert(" + hdnProCheck.ClientID + ".getValue());");

    But this does not?
    this.ScriptManager1.AddScript("alert('" + hdnProCheck.Value + "');");

    So - when I try and check the hidden value from my code behind -it is coming up blank/null
  5. #5

    RE: Set hidden value from JS codebhind not working?

    Hi,

    What you expect with second alert if Value of hidden field is empty?
    You build script until it's execution.


    Here is a list registered script
    hdnProCheck.setValue('1');alert(hdnProCheck.getValue());

    alert('')

    setValue('1') executted on client side after any script building on server side (on server side hdnProCheck.Value is empty)
  6. #6

    RE: Set hidden value from JS codebhind not working?

    So - I am an idiot - is there a way to set the hidden value from server side - in the JS? Reason I was trying trying to do here is - I have a tab panel - from tab1 - I am trying to check the value of a radio button - and set the hidden field on tab1 iframe to that value - so am checking it with "parent.rb1.checked' - not sure if I can do that in the code behind...
  7. #7

    RE: Set hidden value from JS codebhind not working?

    For now - went the querystring route - thanks

Similar Threads

  1. Replies: 3
    Last Post: Feb 21, 2012, 7:46 AM
  2. [CLOSED] Hidden Change and Grid Filters are not working after Grid Reconfigure
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 15
    Last Post: Oct 16, 2011, 1:12 PM
  3. Replies: 5
    Last Post: Sep 21, 2010, 5:08 PM
  4. [CLOSED] Panel / Window Title gets hidden in lesser working space.
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Dec 08, 2008, 9:25 AM

Posting Permissions