difference between code inside a <script> tag and code in the code-behind file

What is the difference between code that exists inside the <html><script runat="server" > tag and code that exists in the code-behind file?

Thanks,

Keith

0
kbrickey
3/28/2006 11:00:06 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

1 Replies
1253 Views

Similar Articles

[PageSpeed] 21
Get it on Google Play
Get it on Apple App Store

There really isn't much of a difference other than the code inside the <script runat="server"> tag is part of the web form while code in a class file is part of the class file and inherited in the web form.

HTH,
Ryan


Ryan Olshan
ASPInsider | Microsoft MVP, ASP.NET
http://ryanolshan.com

How to ask a question
0
StrongTypes
3/28/2006 11:03:24 PM
Reply:

Similar Artilces:

<script runat="server">code</script> in aspx file errors when I try to run same code in mypage.aspx.cs file
This code runs file in the aspx file ---- "Profile" and "MasterPageFile" are defined in Web.config <script runat="server">    protected void Page_PreInit(object sender, EventArgs e)    {        if (Request["master"] != null)        {            switch (Request["master"])            {       ...

Please use <code></code> tags when including code!
Often, I and other moderators, have to enclose Code examples in the above tags to make the Code legible. In your own best interest, please do this always.... It is sometimes almost impossible to read the Code examples at all.RegardsAndre Colbiornsen ---------------------------------Seventh DayRåbygatan 1A,SE-223 61 LundSwedenMob.: +46-(0)708-97 78 79Mail: info@seventhday.se-------------------------------- So, that's how you do it! Any other markup tags we should be aware of?Sanders "Bucky" Kaufman, Jr. SandersKaufman@Hotmail.com www.kaufman.net/bucky Good question! I comp...

Please use <code></code> tags when including code!
Far too often, I and other moderators, have to enclose Code examples in the above tags to make the Code legible. In your own best interest, please do this always.... It is sometimes almost impossible to read the Code examples at all. For an extensive list of Formatting tags; view post 98605RegardsAndre Colbiornsen ---------------------------------Seventh DayRåbygatan 1A,SE-223 61 LundSwedenMob.: +46-(0)708-97 78 79Mail: info@seventhday.se-------------------------------- I don't mind using the code tags, but the font comes out very small and hard to read. Can you please increase the fon...

Code Behind or "<script runat="server">...code...</script>"?
Hi, I've just started learning asp.net after a number of years with VB. A lot of the examples I've been researching have placed the VB code directly onto the .aspx web page with a "<script runat="server">...code...</script>" format rather than placing the code in a "code behind" .vb page. Is there any reason for this other than the fact that you can place all the relevant code onto one example? From a .Net Studio point of view, it's seems to be far easier to use Code Behind, as one can take advantage of the "Auto Complete" features th...

Code-Behind vs <script></script>?
What is the big difference between coding within an .aspx or .ascx file vs using code-behind and separet .vb files? (beside separation of logic and presentation within different files) /Raymond...

How to link to a Java Script file from my .aspx code. Must be done in my <head></head> tags
I am maintaining a VS 2003 .NET 1.1 project.Here is my question:I have a snippet of Java script code that I need to add to every .aspx page in my project. Instead ofcopying and pasting the Java script into each .aspx web form, I would like to create a java script file containingthe Java Script code(Snippet), and then just reference this .js file in each .aspx page.Can someone tell me how to do this in the .aspx code. The link to the Java Script snippet MUST occur in the <Head></Head> tag of my .aspx code. Please don't recommend that I use a web user control. I don't need...

Code-Behind versus Code-Inside and Code-Beside
Can someone explain to me how the code gets compiled when you do code-inside (like in webmatrix) as oposed to code-behind? WHen you do the code-behind I know all the code gets compiled at compile-time into a dll assembly. And I think that code-inside gets compiled at run-time. But what if you have a mixture of the two and you have a dll assembly with code-beside modules, how do they get compiled into the assembly? Maybe I'm wrong or confused, can someone clarify? I'm also aware of the Visual Studio 2005 code-beside also, will that change anything? thanks, Frank For a general...

reusable code
 I have a page of code that instead of putting it in each pags code behind, I would like to be able to jsut include it in the code behind of each page so that it gets executed each time. This way I could jsut edit the one file and th changes woudl be site wide in thepages that have this as an include in the code behind file.What is the bet way to do that? Any examples?Thanks Hi, You could create a base class for the code-behind classes (put every code-behind class to derive from this common base class), when changes to the base class would apply to the derived classes.Thanks,Teemu Ke...

Code-behind and Code-inside
Hello to everyone. Can I know what is meant by code-behind and code-inside? I know that if we want to apply code-behind, we should choose VS.NET and in other words, we need to use WebMatrix if we choose to apply code-inside method. Thanks for ur ideas, thank u ! Is below link answers your question? http://msdn.microsoft.com/asp.net/community/inbox/codebeside/default.aspx My personal asnwer would be I don't like code behind (Which VS.NET 2002/2003 supports) My vote to code seperation model (Next version of VS.Net [Whidbey] supports that)Sreedharhttp://www.w3coder...

Bug rendering <p> tags around <pre> or <code> tags
Name: Tim Robinson Email: tcr1272atgmaildotcom Product: Firefox Summary: Bug rendering <p> tags around <pre> or <code> tags Comments: Two Examples below, both render the <p> tags differently and incorrectly. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <body> <p> <pre> <div> my text </div> </pre> <p> <body> <html> <!DOCTYP...

To code or not to code?
The rise of Open Source software adoption has brought with it increased awareness of non-proprietary programming technologies. http://www.itnews.com.au/Feature/4593,to-code-or-not-to-code.aspx -- "Never drive faster than your ANGEL can fly" ...

Code Behind or not Code Behind
Ok i am confuse now.... A lot of books are showing pages without code behind (the code is integrated in the .aspx) Is it better to use the code behind or not. Is there any difference between using VB.NET or C#.NET except for the code synthax. Thank you and come again. A lot of samples show inline code just for simplicity.. i personally use code-behind because I like to seperate my code from presentation. As for VB.NET or C#, its your preference.. there is no difference really when its all said and done. From a purely mathematical sense, having everything in a single file would s...

what about the code-behind (code behind)
One MAJOR difference between AJAX.NET and Atlas.NET seems to be that AJAX.NET is able to expose methods in your codebehind to the client. Why doesn't Atlas do this? Or am I mistaken? With AJAX.NET it's just a simple line or two:  Ajax.Utility.RegisterTypeForAjax(GetType(myClass)) <Ajax.AjaxMethod()>Public Function myFunction PLEASE tell me Atlas has something comparable to this. I don't have the time to rewrite all my code-behind methods in javascript or atlas script. All you need to do in Atlas to expose a method on your page (or its code behind class) is to put a [WebMet...

code in <script></script> block
 Hi, Why is it that my code for events such as 'FormView1_ItemUpdating' is being inserted into my markup insread of into the aspx.vb file? Thanks  When you added the Web Form to your site, did you make sure to select the "Place code in separate file" CheckBox?Thanks, EdMicrosoft MVP - ASP/ASP.NET Hi, I agree with the member above. If we want Visual Studio .Net to generate code into class file I.E. .aspx.vb file, we need to select the "Place code in separate file" CheckBox when adding web form. ASP.NET supports two modes of ...

Web resources about - difference between code inside a <script> tag and code in the code-behind file - asp.net.getting-started

Resources last updated: 11/21/2015 7:36:59 PM