Solved

Compiler Error Message: BC30188: Declaration expected.

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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