joem824
joem824

Reputation: 59

How can i pass the hidden field value of another page?

Hi I have here a simple representation of the page I want to do.

enter image description here

I want to get the hidden field values of page2.aspx and pass it to the label of page1.aspx using c#.

Can you guys help me tnx :)

Upvotes: 0

Views: 2279

Answers (2)

kavalirakesh
kavalirakesh

Reputation: 33

You can get values from iframe and assigned to parent page.

basically every page is render as html irrespective of languages and technology, so i am using jquery to get the iframe value and assign to parent controls.

Iframe.aspx

<div>
        <asp:Label runat="server" ID="lblInfo">This is Iframe : </asp:Label>

        <asp:HiddenField ID="hidfld1" runat="server" Value="this is test hidden value." />
    </div>

Parent.aspx

    <header>
      <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>

       <script type="text/javascript">
        $(document).ready(function () {

            $('#uploadIFrame').load(function () {
                var $currIFrame = $('#uploadIFrame');
                var $hidval = $currIFrame.contents().find("body #hidfld1").val();
                alert($hidval);

                $("#MainContent_txtInfo").val($hidval);
            });

        });
    </script>

</header>

<body>

    <div>
<asp:TextBox runat="server" Text="test" ID="MainContent_txtInfo"></asp:TextBox>
        <iframe id="Iframe1" scrolling="no" frameborder="0" style="border-style: none; margin: 0px; width: 100%; height: 40px;" src="IFRAME.aspx"></iframe>       
    </div>

</body>

once you got the hidden field value in textbox or label then you can user your c# code to process the value in code behind.

Upvotes: 0

Tummala Krishna Kishore
Tummala Krishna Kishore

Reputation: 8271

HTML

this hidden value is in page 2 that is in iframe

<input type="hidden" id="hdnpage2" runat="server" />

Javascript

on a button click or page load in Page 1 try to call this JS

var iframe = document.getElementById('iframebody');//id of your iframe
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
var hdnvale = innerDoc.getElementById('hdnpage2');
alert (hdnvale.value);

Upvotes: 1

Related Questions