Solved

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

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

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 55

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

691 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