sorry for above comment (it is same as yours ).
======
<script runat=server> it dosent tell server or client that which language should be used so it gives an error.
Main Topics
Browse All TopicsMy understanding is that <% %> brackets server-side script, so I can code
<body>
<h1>
<%
Response.Write("<br>user name is " & User.Identity.Name)
%>
</h1>
and get my page to display the name of the user that just logged in, and this works. But it seems that I should also be able to code
<body>
<h1>
<script runat=server>
Response.Write("<br>user name is " & User.Identity.Name)
</script>
</h1>
and get the same result, but the second code gives the error "Declaration expected."
Does anyone know what's going on?
Thanks,
steva
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
The language is declared in the @page directive as VB. But even putting it explicitly in the opening script tag, as below, doesn't fix the problem. I still get the error "Declaration expected" and Response has wavy line under it. So the system is looking for a declaration where it finds Response.write.
<script type="text/VB" language=vbscript runat=server>
Response.Write("<br>user name is " & HttpContext.Current.User.I
</script>
Ok, I solved this myself. <script runat=server> ... </script> is only used for declaring functions and it can only appear in the head section. You can't put code that isn't a function between them. So ASP.NET 2.0 was looking for the declaration of a function after <script runat=server> and found "Response.Write."
steva
Business Accounts
Answer for Membership
by: ajaysharmaapjsPosted on 2008-05-17 at 00:50:50ID: 21588324
<%
Response.Write("<br>user name is " & User.Identity.Name)
%>