Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Access hidden asp.net objects

Reply
Thread Tools

Access hidden asp.net objects

 
 
tshad
Guest
Posts: n/a
 
      09-10-2007
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


 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      09-10-2007
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

"tshad" <(E-Mail Removed)> a écrit dans le message de news:
http://www.velocityreviews.com/forums/(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      09-10-2007
Server controls with Visible=false don't get rendered to client. Leave
Visible=true and hide with css rule display:none.

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


"tshad" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
tshad
Guest
Posts: n/a
 
      09-10-2007
"Patrice" <http://www.chez.com/scribe/> wrote in message
news:%23S%(E-Mail Removed)...
> 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...


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:

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

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
>
> "tshad" <(E-Mail Removed)> a écrit dans le message de news:
> (E-Mail Removed)...
>> 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
>>

>
>



 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      09-10-2007
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/lib...ddenfield.aspx
allows to easily render an hidden field (and as said earlier, note that view
source is enoguh to show its content).

---
Patrice

"tshad" <(E-Mail Removed)> a écrit dans le message de news:
(E-Mail Removed)...
> "Patrice" <http://www.chez.com/scribe/> wrote in message
> news:%23S%(E-Mail Removed)...
>> 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...

>
> 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:
>
> <aspanel ID="EmailPanel" visible=false runat="server">
> <asp:TextBox ID=Email runat="server"/>
> </aspanel>
>
> 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
>>
>> "tshad" <(E-Mail Removed)> a écrit dans le message de news:
>> (E-Mail Removed)...
>>> 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
>>>

>>
>>

>
>



 
Reply With Quote
 
tshad
Guest
Posts: n/a
 
      09-10-2007
"Eliyahu Goldin" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> 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 <aspanel 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
>
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]
> http://msmvps.com/blogs/egoldin
> http://usableasp.net
>
>
> "tshad" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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
>>

>
>



 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      09-10-2007
> 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"


 
Reply With Quote
 
tshad
Guest
Posts: n/a
 
      09-10-2007
"Eliyahu Goldin" <(E-Mail Removed)> wrote in
message news:%(E-Mail Removed)...
>> 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"
>

That's what I needed to know.

Thanks,

Tom


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate Hidden field on post back and retrieve value from Hidden Field Rick ASP .Net 3 04-13-2010 05:38 PM
Win 7 folders hidden despite 'show hidden' checked Boppy NZ Computing 10 01-23-2010 02:56 AM
class objects, method objects, function objects 7stud Python 11 03-20-2007 06:05 PM
Hidden objects given error tshad ASP .Net 3 02-24-2007 01:50 PM
How would I discover the text in a block element hidden by overflow:hidden style being set? SolarCanine Javascript 2 09-20-2005 06:27 PM



Advertisments