?
Solved

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

Posted on 2011-03-11
4
Medium Priority
?
445 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 58

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 58

Accepted Solution

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

765 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