Passing property values from popup to Main Webform?

G

Guest

How can I pass variable or Property values from my popup webForm to the
webform that opened this popup?
For information that's in a control (i.e. Textbox), I'm using javascript and
document.getElementById:

var variable = document.getElementById('txtBox).value;

But if the control is hidden, that javascript code generates an error. Can
this be done with properties?
Thanks.
 
M

Mark Rae

How can I pass variable or Property values from my popup webForm to the
webform that opened this popup?
http://msdn.microsoft.com/library/d...r/dhtml/reference/methods/showmodaldialog.asp

For information that's in a control (i.e. Textbox), I'm using javascript
and
document.getElementById:

var variable = document.getElementById('txtBox).value;

I'm assuming that the missing apostrophe after txtBox is just a typo...?
But if the control is hidden, that javascript code generates an error.

Sigh - WHAT ERROR DOES IT GENERATE?
Can this be done with properties?

Yes.
 
B

bruce barker \(sqlwork.com\)

there is hidden (type=hidden) and invisible. javascript can see hidden
fields. fields marked invisible are not render, so the brwser does not see
them.

-- bruce (sqlwork.com)
 
G

Guest

Thanks for the post. Sorry about the vague post.
The missing apostrophe was just a typo when I posted the message.
The error I get when I try to get the server-side textBox value (when
visible= false) is "Object Requred". If I make it visible, it works. The
problem is that this information doesn't need to be displayed.
I'm using server-side textboxes because they interact with a gridview and I
feel more comfortable with them. So I can't use (Type= hidden).
How can this be done with properties instead of retrieving the value of the
Textbox?
Thanks.
 
G

Gozirra

Try this.

<asp:TextBox style="display:none" runat="server"
ID="txtTest"></asp:TextBox>

It will still render and your javascript will work as expected.
 
G

GroupReader

Yes, I agree with Gozirra.

Some more information: for server-side textboxes, if you set the
Visible property = false, then asp.net tries to be "smart" and does not
render the text box at all. This is not what you want and is
completely different from rendering a textbox that is not visible.

Three common ways to solve your issue:
1) CSS Solution: Like Gozirra said, use the display:none style
2) Asp.Net 1.1 Solution: In the code-behind, use
"Attributes.Add(visible, false)". This will set the html visible
property to false, not the ASP.Net Visible property.
3) Asp.Net 2.0 Solution: Asp.net 2.0 has a new control to solve this
issue called: <asp:hiddenfield>. This is probably the preferred way
to do it in asp.net 2.0. Microsoft created the hiddenfield control to
solve the problem you are having. Use a HiddenField control instead of
a TextBox.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top