Connecting Tech Pros Worldwide Help | Site Map

Datagrid invisible Label/Textbox does not generate HTML Object?

rockdale
Guest
 
Posts: n/a
#1: Jun 6 '06
Hi, All:

I have a datagrid with TemplateColumn as following:

<asp:TemplateColumn Visible="False" >
<ItemStyle Width="0px"></ItemStyle>
<ItemTemplate>
<asp:Label id="lblMin_Value" Visible=False runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.min_value") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>

I set Visible = false for this column because I do not want end user
see this column. But
If I check the html source, I did not see any HTML code for this label.
If the Visble is true, on the source code of HTML, I will see <Span id
= blahblah....>. I have a client side javascript to using this label's
value (actually the span's innerText), but the HTML does not have this
<Span object, so I could get the value of this min_value.

I also tried to set Visible =FAlse for <ASP:Label , it is the same.
I tried using <ASP:textbox > it is the same, not HTML object generated.


Does anybody have experience on this before? How should I Invisible an
Label/Textbox in datagrid but generate HTML Object so that JavaScript
can access?

Thanks a lot
-Rockdale

sloan
Guest
 
Posts: n/a
#2: Jun 6 '06

re: Datagrid invisible Label/Textbox does not generate HTML Object?



Add a hidden object.

what you see is what is supposed to be doing.


<input id="hidUserUUID" type="hidden" name="hidUserUUID" runat="server">

something like that.



"rockdale" <rockdale.green@gmail.com> wrote in message
news:1149625142.600480.8520@j55g2000cwa.googlegrou ps.com...[color=blue]
> Hi, All:
>
> I have a datagrid with TemplateColumn as following:
>
> <asp:TemplateColumn Visible="False" >
> <ItemStyle Width="0px"></ItemStyle>
> <ItemTemplate>
> <asp:Label id="lblMin_Value" Visible=False runat="server" Text='<%#
> DataBinder.Eval(Container, "DataItem.min_value") %>'>
> </asp:Label>
> </ItemTemplate>
> </asp:TemplateColumn>
>
> I set Visible = false for this column because I do not want end user
> see this column. But
> If I check the html source, I did not see any HTML code for this label.
> If the Visble is true, on the source code of HTML, I will see <Span id
> = blahblah....>. I have a client side javascript to using this label's
> value (actually the span's innerText), but the HTML does not have this
> <Span object, so I could get the value of this min_value.
>
> I also tried to set Visible =FAlse for <ASP:Label , it is the same.
> I tried using <ASP:textbox > it is the same, not HTML object generated.
>
>
> Does anybody have experience on this before? How should I Invisible an
> Label/Textbox in datagrid but generate HTML Object so that JavaScript
> can access?
>
> Thanks a lot
> -Rockdale
>[/color]


Bob Barrows [MVP]
Guest
 
Posts: n/a
#3: Jun 6 '06

re: Datagrid invisible Label/Textbox does not generate HTML Object?


rockdale wrote:[color=blue]
> Hi, All:
>
> I have a datagrid with TemplateColumn as following:
>
> <asp:TemplateColumn Visible="False" >
> <ItemStyle Width="0px"></ItemStyle>
> <ItemTemplate>
> <asp:Label id="lblMin_Value" Visible=False runat="server" Text='<%#
> DataBinder.Eval(Container, "DataItem.min_value") %>'>
> </asp:Label>
> </ItemTemplate>
> </asp:TemplateColumn>
>
> I set Visible = false for this column because I do not want end user
> see this column. But
> If I check the html source, I did not see any HTML code for this
> label. If the Visble is true, on the source code of HTML, I will see
> <Span id = blahblah....>. I have a client side javascript to using
> this label's value (actually the span's innerText), but the HTML does
> not have this <Span object, so I could get the value of this
> min_value.
>
> I also tried to set Visible =FAlse for <ASP:Label , it is the same.
> I tried using <ASP:textbox > it is the same, not HTML object
> generated.
>
>
> Does anybody have experience on this before? How should I Invisible an
> Label/Textbox in datagrid but generate HTML Object so that JavaScript
> can access?
>[/color]
The effect of setting any server control's Visible property to False is
to prevent that control from being rendered on the client.

You will need to use a client-side solution for this, perhaps a css
class:

<style>
.invisible {display:none}
</style>
....
asp:Label id="lblMin_Value" CssClass="invisible" runat="server" Text=


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


rockdale
Guest
 
Posts: n/a
#4: Jun 7 '06

re: Datagrid invisible Label/Textbox does not generate HTML Object?


Brilliant.

I came with
<asp:TemplateColumn ItemStyle-CssClass="invisible"
FooterStyle-CssClass="invisible" HeaderStyle-CssClass="invisible"
ItemStyle-Width=0>

and it works perfect

Thank you very much
-rockdale


Bob Barrows [MVP] wrote:[color=blue]
> rockdale wrote:[color=green]
> > Hi, All:
> >
> > I have a datagrid with TemplateColumn as following:
> >
> > <asp:TemplateColumn Visible="False" >
> > <ItemStyle Width="0px"></ItemStyle>
> > <ItemTemplate>
> > <asp:Label id="lblMin_Value" Visible=False runat="server" Text='<%#
> > DataBinder.Eval(Container, "DataItem.min_value") %>'>
> > </asp:Label>
> > </ItemTemplate>
> > </asp:TemplateColumn>
> >
> > I set Visible = false for this column because I do not want end user
> > see this column. But
> > If I check the html source, I did not see any HTML code for this
> > label. If the Visble is true, on the source code of HTML, I will see
> > <Span id = blahblah....>. I have a client side javascript to using
> > this label's value (actually the span's innerText), but the HTML does
> > not have this <Span object, so I could get the value of this
> > min_value.
> >
> > I also tried to set Visible =FAlse for <ASP:Label , it is the same.
> > I tried using <ASP:textbox > it is the same, not HTML object
> > generated.
> >
> >
> > Does anybody have experience on this before? How should I Invisible an
> > Label/Textbox in datagrid but generate HTML Object so that JavaScript
> > can access?
> >[/color]
> The effect of setting any server control's Visible property to False is
> to prevent that control from being rendered on the client.
>
> You will need to use a client-side solution for this, perhaps a css
> class:
>
> <style>
> .invisible {display:none}
> </style>
> ...
> asp:Label id="lblMin_Value" CssClass="invisible" runat="server" Text=
>
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.[/color]

Closed Thread