Solved

Compiler Error Message: BC30188: Declaration expected.

Posted on 2010-08-19
2
812 Views
Last Modified: 2013-11-07
Partial Class ABC
   Inherits System.Web.UI.Page

    Dim newStyleSheet As New HtmlLink()
    newStyleSheet.Href = "include/StyleSheet.css"   
    newStyleSheet.Attributes.Add("rel", "stylesheet")    
    newStyleSheet.Attributes.Add("type", "text/css")    
    'Page.Header.Controls.Add(link)

End Class

Open in new window

I want to add a stylesheet in the codebehind using this simple code snippet, my page doesn't have anything else.
I got Declaration expected error when do a 'build page' as well as when 'view in Browser' in localhost.

When I typed in a dot after an object, a contex menu appears with a bunch of object' members, what namespace I should import in this case for newStyleSheet? cause I don't see anything....

what's wrong with my page? Thx
0
Comment
Question by:MercuryKT
  • 2
2 Comments
 
LVL 27

Accepted Solution

by:
nmarun earned 125 total points
ID: 33482184
Your statements need to be either in a constructor or a method or an event, just can be dangling like there in a class.


Arun
0
 
LVL 27

Assisted Solution

by:nmarun
nmarun earned 125 total points
ID: 33482201
Something like below.

Arun

Public Partial Class ABC Inherits Page

	Protected Sub Page_Load(sender As Object, e As EventArgs)

		Dim newStyleSheet As New HtmlLink()

		newStyleSheet.Href = "include/StyleSheet.css"

		newStyleSheet.Attributes.Add("rel", "stylesheet")

		newStyleSheet.Attributes.Add("type", "text/css")

		'Page.Header.Controls.Add(link)

	End Sub

End Class

Open in new window

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
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…

707 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

13 Experts available now in Live!

Get 1:1 Help Now