Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

div tags - asp.net 3.5 app

Posted on 2011-03-10
13
Medium Priority
?
390 Views
Last Modified: 2012-08-13
I have div tags in my html code (see the code example bellow)

Now, I am trying to make them visible and invisible (based on criteria) in my asp.net code by doing this:

  div1.Style("Display") = True
        div2.Style("Display") = "none"

But it tells me that Div1 "is not declared."
 



<asp:Repeater ID="Repeater1" runat="server">
<%--                     <headertemplate>
                     
                     </headertemplate>--%>
                     <ItemTemplate>
                     <font size="2" <b><label style="padding-right:93px;">Category ID</label><%#Eval("Category_ID")%></font>                                                
                        <br />
                         <font size="2"  ><label style="padding-right:82px;">Category Path</label><%#Eval("Category_ID")%></font>
                        <br />
                        <font size="2"><label style="padding-right:126px;">Name</label><%#Eval("Category_Name")%></font>
                        <br />
                        <font size="2"><label style="padding-right:93px;">Description</label><%#Eval("Category_Description")%></font>
                       <br />
                        <font size="2"><label style="padding-right:67px;">Parent Category</label><%#Eval("Parent_Category_ID")%></font>
                       <br />
                               <div id="div1" runat="server">
                                      <asp:Label ID="lblNoMainImage" runat="server" Text="No Image"></asp:Label>
                                    </div>

                                    <div id="div2" runat="server">
                                         <asp:HyperLink ID="hlMainImageView2" NavigateUrl="javascript:OpenChild('main');"
                                             runat="server">View</asp:HyperLink>
                                            &nbsp;
                                      &nbsp;

                                    </div>  

                       <br />                                          
                      </ItemTemplate>
                   
                    </asp:Repeater>
0
Comment
Question by:vbnetcoder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 6

Expert Comment

by:Webmonkey
ID: 35095726
Since the Divs are in a repeater control, they aren't listed in the Page.Controls collection.  Insteadm they are in the Repeater.Controls collections.  I suggest something like Repeater1.Controls.FindControl("div1").  I haven't tried this, but I'm sure its very close.
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35095781
as an aside the opposite of
div1.Style("Display") = "none"
is
div1.Style("Display") = ""
0
 

Author Comment

by:vbnetcoder
ID: 35096258
Webmonkey:

How what would be the code then to make the divs visible or invisible?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35096303
to make invisible :
div.Style("display") = "none"
to make visible :
div.Style("display") = ""
0
 
LVL 11

Expert Comment

by:SAMIR BHOGAYTA
ID: 35096360
Hi, first you have to use the css for creating the div design then after you have to set the visible property of div into your coding part.
0
 

Author Comment

by:vbnetcoder
ID: 35096419
How would i do that in conjunction with the find method...

simply doing this will not work:

 Repeater1.FindControl("div1")
        Repeater1.FindControl("div2")

        div1.Style("Display") = True
        div2.Style("Display") = "none"
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35096738
try this :

Repeater1.FindControl("div1").Style("display") = "none"

However you may be better doing it in javascript.

A good artile for what you are trying to achieve :

http://www.4guysfromrolla.com/articles/091504-1.aspx#postadlink
0
 
LVL 6

Expert Comment

by:Webmonkey
ID: 35096827
If you want to use CSS to hide the control, then you could use:

Repeater1.FindControl("div1").Style("display") = "none";

Open in new window


If you don't want the server to send the control at all, then you would address the visible property in .Net, like so:

Repeater1.FindControl("div1").Visible = False;

Open in new window

0
 

Author Comment

by:vbnetcoder
ID: 35097098
When I do that it tells me that style is not a member of system.web.ui.control
0
 
LVL 6

Accepted Solution

by:
Webmonkey earned 2000 total points
ID: 35097379
Ah, right, sorry.  Try this:

Repeater1.FindControl("div1").Style["display"] = "none";

Open in new window


Style is a collection, not a method.
0
 

Author Comment

by:vbnetcoder
ID: 35097774
I still get style is not a member of system.web.ui.control

0
 
LVL 6

Expert Comment

by:Webmonkey
ID: 35100174
What version of the .Net Framework are you using?
0
 

Author Closing Comment

by:vbnetcoder
ID: 35157664
ty
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question