Solved

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

Posted on 2011-03-11
4
434 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now