Solved

Help solving problem - "Public member 'Attributes' on type 'String' not found"

Posted on 2011-03-11
4
441 Views
Last Modified: 2012-05-11
Hi - I need some help solving this problem.  I'm looping through a DataTable, passing values (The values are Div IDs) to a Sub routine in order to make Divs visable on my aspx page.  Currently it doesn't work.  I'm getting an error of:

Public member 'Attributes' on type 'String' not found

Can someone please look at my code and let me know how to fix it?
Imports System.Data

Partial Class MyClass
    Inherits System.Web.UI.Page

    Dim strPickTicketID As String
    Dim MyBLL As New PickPackItemsBLL
    Dim dt As DataTable

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        strPickTicketID = "4"

        dt = MyBLL.GetPickTicketItems(strPickTicketID)

        For Each row As DataRow In dt.Rows
            Call SetVisibility(row.Item("Shelf"))
        Next

    End Sub

    Sub SetVisibility(ByVal DivID As Object)
        DivID.Attributes.Add("style", "visibility:visible;")
    End Sub
End Class

Open in new window

0
Comment
Question by:cdemott33
[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
  • 2
  • 2
4 Comments
 
LVL 51

Expert Comment

by:Huseyin KAHRAMAN
ID: 35110665
maybe this

Sub SetVisibility(ByVal DivID As String)
  dim myDiv as control = me.FindControl(DivID)
  myDiv.Attributes.Add("style", "visibility:visible;")
End Sub

assuming you have lots of divs on aspx like this

<div runat=server id=DivA>....</div>
<div runat=server id=DivB>....</div>

and from db, you get "DivA", "DivB" etc...

0
 

Author Comment

by:cdemott33
ID: 35110720
You are correct.  My divs are set up exactly as you noted.

I added the code you suggested but got the following error
Compiler Error Message: BC30456: 'Attributes' is not a member of 'System.Web.UI.Control'.

Source Error:

 

Line 22:     Sub SetVisibility(ByVal DivID As Object)
Line 23:         Dim myDiv As Control = Me.FindControl(DivID)
Line 24:         myDiv.Attributes.Add("style", "visibility:visible;")
Line 25:     End Sub
Line 26: End Class

Open in new window

0
 
LVL 51

Accepted Solution

by:
Huseyin KAHRAMAN earned 500 total points
ID: 35110738
try this as is

Sub SetVisibility(ByVal DivID As String)
  dim myDiv as control = me.FindControl(DivID)
  myDiv.Visible = True
End Sub

assuming you set visible= false by default like

<div runat=server id=DivA visible=false>....</div>
<div runat=server id=DivB visible=false>....</div>

0
 

Author Closing Comment

by:cdemott33
ID: 35110831
Excellent!  That worked.  Thanks you for your help.  It was greatly appreciated.
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

740 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