Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

Access hidden asp.net objects

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tshad - 10 Sep 2007 16:58 GMT
How do you hide an asp.net object and still be able to access it?

I had my email in a session variable, but you can't access the session
variable from Javascript (I don't think - since Javascript is Client and
Session is Server).

I tried using the email that was on the page, but it was surrounded by a
Panel that had its visible property set to false - so anything inside of the
Panel was not on the page.

I also tried to set a variable:

       <asp:Label ID="emailSave" Visible="false" runat="server"/>

But I had the same problem as the Panel, it wasn't on the page.

I am trying to access this from a page I open so this page is now the
opener.

How can I hide a variable and still get access to it via the Javascript?

Thanks,

Tom
Patrice - 10 Sep 2007 17:08 GMT
Not sure what you mean by "hidding". You can render this value as an hidden
field or by rendering dynamically created JavaScript so that this is usable
client side (in both cases "view source" will reveal the value).

What do you do with this value ? If you don't need this client side, just
retrieve this server side at will rather than passing this value to the
client just to postback the value to the server...

---
Patrice

> How do you hide an asp.net object and still be able to access it?
>
[quoted text clipped - 20 lines]
>
> Tom
tshad - 10 Sep 2007 17:16 GMT
> Not sure what you mean by "hidding". You can render this value as an
> hidden field or by rendering dynamically created JavaScript so that this
[quoted text clipped - 3 lines]
> retrieve this server side at will rather than passing this value to the
> client just to postback the value to the server...

I am trying to do this to get access from Javascript (clientSide) to my
variables on my parent page.

The problem is that if I do something like:

<asp:Panel ID="EmailPanel" visible=false runat="server">
   <asp:TextBox ID=Email runat="server"/>
</asp:Panel>

or

<asp:Label ID="EmailSave" Visible=false/>

In either case, the variables do not seem to be on the page so JavaScript
can't see them.

I need this value to put onto the page that I am opening up.

Thanks,

Tom

> ---
> Patrice
[quoted text clipped - 23 lines]
>>
>> Tom
Patrice - 10 Sep 2007 17:26 GMT
Expected. When you set visible to false server side it is not rendered at
all in the resulting HTML code (unlike using display:none for example).

http://msdn2.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.regis
terhiddenfield.aspx

allows to easily render an hidden field (and as said earlier, note that view
source is enoguh to show its content).

---
Patrice

>> Not sure what you mean by "hidding". You can render this value as an
>> hidden field or by rendering dynamically created JavaScript so that this
[quoted text clipped - 54 lines]
>>>
>>> Tom
Eliyahu Goldin - 10 Sep 2007 17:10 GMT
Server controls with Visible=false don't get rendered to client. Leave
Visible=true and hide with css rule display:none.

Signature

Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net

> How do you hide an asp.net object and still be able to access it?
>
[quoted text clipped - 20 lines]
>
> Tom
tshad - 10 Sep 2007 18:16 GMT
> Server controls with Visible=false don't get rendered to client. Leave
> Visible=true and hide with css rule display:none.

That worked great.

If I set the Panel display:none, will it work the same way and hide the
controls but leave them on the page?

Is there a way to set this from vb.net during processing?

I periodically set visible to false to hide a control or section of HTML
with controls on them.  This is usually done by <Div id="something"
runat=false> or <asp:Panel id = "something" runat=false> and then setting
something.visible=false.

This works pretty well most of the time.

But sometimes I do need to get access to the variables from Javascript - so
visible=false won't work.

So where I do something like this to hide panel in my asp.net code:

thePanel.visible = false

Is there a better way to do this so I can get access to the variables from
the panel?

How would I set style="display:none" from asp.net?

Thanks,

Tom

>> How do you hide an asp.net object and still be able to access it?
>>
[quoted text clipped - 20 lines]
>>
>> Tom
Eliyahu Goldin - 10 Sep 2007 19:44 GMT
> If I set the Panel display:none, will it work the same way and hide the
> controls but leave them on the page?
Yes

> How would I set style="display:none" from asp.net?
The easiest thing would be to make a css class

.Invisible{display:none}

Then you could set

something.CssClass="Invisible"

or

something.Attributes("class")="Invisible".

You also can do

something.Attributes("style")="display:none"
tshad - 10 Sep 2007 22:33 GMT
>> If I set the Panel display:none, will it work the same way and hide the
>> controls but leave them on the page?
[quoted text clipped - 16 lines]
>
> something.Attributes("style")="display:none"

That's what I needed to know.

Thanks,

Tom

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.