Solved

Compiler Error Message: BC30188: Declaration expected.

Posted on 2010-08-19
2
816 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 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