Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing a textbox value on the parent form

Status
Not open for further replies.

dpdoug

Programmer
Nov 27, 2002
455
US
I have a web form (let's call it MainForm) with a textbox to get a certain date from the user. I need to store this date somehow server-side for later use. It was working fine while I was having the user click on the button on Mainform, but because of the client's specifications, I can't use a button to store this value, so I had to take it off. Now I'm trying to figure a way to get that value.

I have an iFrame (let's call it MyFrame) that has a web form in it that posts values to the database. At the time it posts, I need to be able to get the Date from the textbox on MainForm to post with the rest of the data.

I tried triggering a submit on the onblur event of the textbox to try to save the value to a variable on the server, but that didn't work. I tried accessing the textbox's value using the parent property, that didn't work either.
 
hi, i am not that skiled in asp.net. but with my limited kn owledge , i feel sending thru get or post method will help..or u can have hidden field right
 
dp: I have successfully pulled text values from the Main page into an IFrame aspx page by referencing accordingly:

iftext.Text = '<%=txtMyText.Text%>'

See if you have any luck with this (you might also try this using a declared string variable).
 
My problem is getting the value into the variable. Since an asp:textbox has only 2 events, and neither of them will trigger getting the value into some kind of variable on the server, I have to grab it some way on the client side.

If I could use the onload event of the page loading into the iframe to grab the values from the parent page and put them into hidden text boxes, that would work for me.

This is conceptually what I need:

Code:
MyIframe.MyIframeTextbox.Value = ParentForm.ParentFormHiddenTextbox.value

I could even use the onclick event to grab the value from the iframe. I just can'tuse it on the parent form.

David
 
David - just a thought - you could trigger javascript OnLoad and perhaps use something on the order of

Code:
.....=" + document.forms["Form1"].elements["txtMyText"].value....

..just a thought.
 
The problem is that this doesn't grab the value from the parent form. The javascript OnLoad event would have to be triggered in the web form in the iframe.

 
David,
David said:
I have an iFrame (let's call it MyFrame) that has a web form in it that posts values to the database
How are you posting values from within the form in the iFrame?


JC


Friends are angels who lift us to our feet when our wings have trouble remembering how to fly...
 
David --

I have a main form aspx page, with an IFRAME embedded in it. When I post back the IFRAME aspx page, it can obtain a value from the parent form using '<%=strVar%>' in the IFRAME aspx page - that is what I was making reference to.

If you are posting back your IFRAME, MyFrame, I don't know why this doesnt work.

In my sitation I have a button on the IFRAME aspx page, and when I click on it to post it back, it then gets the parent form value using the above technique.
 
There is a web form in the iFrame (MyFrame).

I'm pulling data from the database from that web form that the user would select to put in the order when he clicks the button 'Add to Cart'. The thing is that there has to be a begin date and a return date to go with each item in the order that could possibly be different for each item.

Since I can't use a button to cause a postback to store the value on the server, I have to get the value from the client side.

The problem is getting the date values in the parent webform from the web form inside the iFrame to post it together with the rest of the values to the database.

 
DP - ok, I see what you're up to. Have to run this evening but what comes to mind is the document.getElementById technique.

I have been to one javascript (IFRAME) site in the past, had dozens of examples of exchanging params between the parent form and the IFRAME but can't locate the URL at the moment. I'll continue looking for it.
 
DP - one other note; I have had a lot of success over at the Java forum getting questions like this answered - and since its primarily client side you might post there; you probably already know this but those guys over there are pretty rambuncious.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top