How to read value/text in a textbox control (<asp:TextBox ID="Text1" runat="server">

Hello folks,

I have a small popup widow that gets launched successfully using the following code:

 function OpenWindow_HistoricalRuns() {

            var windowIncsimHistRuns = window.open('MVal.aspx', 'Market', 'width=350,height=425,scrollbars=0');

            windowIncsimHistRuns.moveTo(500, 300);

        }

When the popup window is launched successfully I am actually storing a value “Market” in a hidden text box as shown below:

function SetDisplay() {

              document.getElementById('<%=TextBoxSourcePageName.ClientID%>').value = window.parent.name;

          }

Now in the Page_LOad event of the popup window, I want to see what is stored in the hidden text box control (TextBoxSourcePageName). I am using the following asp.net c# code in the Page_load event. But I don’t get anything even though the hidden control has the text “Market”.

 protected void Page_Load(object sender, EventArgs e)
        {

            if (!this.IsPostBack)
            {
                try
                {
                    if (TextBoxSourcePageName.Text == "MarketVal")
               }
           }
        }
                    {

I think i know the reason for not being able to see the text in TextBoxSourcePageName control.

When the popup form is loaded, until the code in page_load event is done (finished execution), the SetDisplay function in body tag of the popup window will not be executed. That is whey in the page_load event of the popup form, when i try to read the value of TextBoxSourcePageName control, I don’t get anything.

Now the challenge is how to pass the parameter in a different way then.
any suggestions?
thanks

In think your problem is with the Javascript “getElementById” call.
This method finds an HTML element based on its CSS ID. You are passing the method an ASP tag. You need to find the “rendered” HTML tag and call it by that ID.

Understood.

In my situation, I need to know the window.parent.name by the time Page_load event gets triggered on the popup window. Because I have to do some specific thing in the Page_Load event (of popup window), based on window.parent.name.

So my fundamental question is, which one will get fired first in an .aspx page.

  1. Javascript in the body tag
    or 2. Page_load event?

If Javascript function in the body tag gets fired first, then by the time I get to Page_Load event, I should already have whatever I need.

thanks

Got my answer. Thanks