understanding inline code <%...%>?

What components can be accessed within a code rendering block (<%...%>)?

When an aspx file is loaded into an assembly, how is this code added to the Page instance.

i.e.

<%
    [Where does the code here go?  What does it have access to?  Is this code added to somewhat of an entry point function like a "void main(args){...}" such that execute functions of associative objects]
%>

LVL 5
TertioptusAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aspmaestroCommented:
In asp.net, the code rendering block can contain only the executable statements, and you can not write the procedure/function inside it. Procedures/functions have to be written inside the <script....></script> blocks. asp.net does not support the page render functions i.e. function inside the <%...%>.
0
sriggummaCommented:
Tertioptus,

Code rendering blocks are denoted with <% ... %> elements, allow you to custom-control content emission, and execute during the render phase of Web Forms page execution.
Code enclosed by <% ... %> is just executed, while expressions that include an equal sign, <%= ... %>, are evaluated and the result is emitted as content. Therefore <%="Hello World" %> renders the same thing as the C# code <% Response.Write("Hello World"); %>.

Important: Unlike ASP -- where functions could be declared within <% %> blocks -- all functions and global page variables must be declared in a <script runat=server> tag. Functions declared within <% %> blocks will now generate a syntax compile error
Server-side comments enable page developers to prevent server code (including server controls) and static content from executing or rendering. The following sample demonstrates how to block content from executing and being sent down to a client. Note that everything between <%-- and --%> is filtered out and only visible in the original server file, even though it contains other ASP.NET directives.

Search Web with "Web Forms Syntax Reference" so that you can find more information.

Hope this helps.

0
sriggummaCommented:
0
TertioptusAuthor Commented:
yes, but what scope is the code in.  

I know that you can have iterative statments (for... to)  and access the Container class, but I'm not sure where access to these objects and methods are coming from.

Is the inline code more like javascript that has access to a few server side objects?
0
sriggummaCommented:
All Protected and Public objects/methods of the Page are accesible within <% %>

The variables which are last updated, if any required, in Page_PreRender before they are used with in <%%>

So almost all Server side objects, except a few, can be used with inline code too.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.