0

This is how i pass value to the page called in iframe

<script type="text/javascript">
        function refreshConversatio() {
            document.getElementById('ifrmConversation').src = 'Default2.aspx?id=' + document.getElementById('<%=HiddenField1.ClientID %>').value;
        }

    </script>

This is How i recieve value in othe page which is being loaded in iframe

 <script type="text/javascript">
        function getParameterByName(name) {
            name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
            var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
                results = regex.exec(location.search);
            return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
        }
        function myLoad() {
            document.getElementById('<%=hdn.ClientID%>').Value = getParameterByName("id");
        }
    </script>


       <asp:HiddenField ID="hdn" runat="server" />


    <script type="text/javascript">
        myLoad();
    </script>

I think that there is problem somewhere (might be in myLoad() ) because i am not able to recieve passed value. What am i doing wrong here?

Mangal Pandey
  • 109
  • 13

3 Answers3

0

Please refer this SO answer to know how to call a function in iframe from parent window:

Calling javascript function in iframe

Community
  • 1
  • 1
webcoder
  • 656
  • 6
  • 12
  • @BlaxingCoder Thank you for your answer, but i am able to call iframe page, but not being able to pass hidden field value successfully – Mangal Pandey Oct 19 '13 at 04:21
0

In order to get the value of hidden field try the following:

var abc =  document.getElementById('hdn');  

or

var abc =  document.getElementById('hdn').value;
Pooja Shrigod
  • 165
  • 1
  • 1
  • 13
0

Try this sample way

code

<asp:HiddenField ID="hf_myhiddenfield" runat="server" Value="hidden value"/>

You can use a Javascript function to insert the value into your onclick attribute

onclick

onclick="window.open('../New/FeedbackV4.aspx'+GetHFValue(),'FeedbackWindow','width=960,height=640,scrollbars=yes,resizable=yes,status=yes')"  

Javascript

<script type="text/javascript">
    function GetHFValue() {
        var hf_value = '?' + document.getElementById("<%= hf_myhiddenfield.ClientID %>").value;
        return hf_value;
    }
</script>

The above code sample is here

and Call this below code for get query string value

/*
* <summary>
* Get the querystring value
* </summary>
* <param name="key">A string contains the querystring key</param>
* <param name="defaultVal">Object which get returns when there is not key</param>
**/
function getQuerystring(key, defaultVal) {
    if (defaultVal == null) {
        defaultVal = "";
    }
    key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
    var qs = regex.exec(window.location.href);
    if (qs == null) {
        return defaultVal;
    }
    else {
        return qs[1];
    }
}
Community
  • 1
  • 1
Ramesh Rajendran
  • 37,412
  • 45
  • 153
  • 234