Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP.NET Compiler Complaints: <%...value...%> & Tag repetition

Status
Not open for further replies.

dushkin

Programmer
Mar 28, 2002
90
US
Hi.
I am trying to come up to speed with ASP.NET and am translating some of my old asp files. I have a few questions here.

1)

I am wondering why "<% value %>" is causing so many problems when i am trying to translate a VBScript to C#. For example, what would

src="project/navBar.asp?url=<%=Server.URLEncode(Request.QueryString("url"))%>"

look like translated to C#/ASP.NET? The compiler keeps telling me that

"I need to quote values differently inside a <%..value..%>
block"

2) My second question is the question of tag repetition. Is there any way around this. My default page has a if... then... else statement that checks for browser type and displays accorgingly. so:

If (browserversion)
<head>
display information
</head>

if (browserversion)
<head>
display information
</head>

and so on. ASP.NET compalins about the tag repetition which
i am not sure how to get around.

Thanks inadvance.

Thanks in advance.
Peter

 
Peter --

Just a couple of thoughts, having little to no experience with asp. In ASP.NET to send a QueryString you simply use:

Code:
...
Response.Redirect("mypage.aspx?id=6")
...

if you have a variable you could use:

...
Dim strVar As String = Request.QueryString("url")
Response.Redirect("mypage.aspx?id='" & strVar & "'")
...

For your duplicate headings my guess is to use one heading and try to insert the variable using javascript; or a combination of javascript and dot NET code behind, but in the end you could probably get the variable in as:

if (browserversion) 'get value from js/code behind
<head>
'<%=strText%>'
</head>

..the point being keep the headers tags down to one set.  Haven't tested this out.  I have a couple of routines that obtain values in code behind and place information in several tags this way, and checking window size, etc., using javascript.  The below example checks window size, then either turns on or leaves turned off scroll bars e.g., 

...
<body background="images/lgtbrown.gif" onLoad="getSWidth();">
...

..with the function in a separate javascript page:
function getSWidth(){
 if (screen.width < 801)
  document.body.style.overflow= "auto";  
}
...

And in the header of the aspx page make a reference to where the javascript can be found, q.v., 

...
<script language="JavaScript" type="text/JavaScript" src="pgTool.js"></script>
...

There will surely be variations on this; but this hopefully gets you thinking in the ball park somewhere...perhaps someone will drop by and add their 2 cents...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top