Solved

Compiler Error Message: BC30188: Declaration expected.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Syntax error 9 45
Help with Syntax 9 29
VB.NET return row from SQL to DataSet and get column values ? 3 31
compare between entities in entity framework 8 12
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…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

28 Experts available now in Live!

Get 1:1 Help Now