Solved

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

Posted on 2011-03-11
4
436 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
  • 2
  • 2
4 Comments
 
LVL 51

Expert Comment

by:HainKurt
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:
HainKurt 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

832 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